Common.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace app\mobile\controller;
  3. use app\mobile\logic\CommonLogic;
  4. use app\admin\logic\CommonLogic as AdminCommonLogic;
  5. use app\BaseController;
  6. use app\mobile\logic\AccountLogic;
  7. use app\model\CommonModel;
  8. use think\exception\ValidateException;
  9. use think\facade\Config;
  10. use think\facade\Validate;
  11. //公共
  12. class Common extends BaseController
  13. {
  14. //省市区编码
  15. public function area()
  16. {
  17. $parent_code = $this->request->post('parent_code', '');
  18. return AdminCommonLogic::getAddr($parent_code);
  19. }
  20. //视频列表
  21. public function getVideoList()
  22. {
  23. $param = $this->request->only(['page' => 1, 'size' => 10], 'post');
  24. return CommonLogic::getVideoList($param);
  25. }
  26. //手机主题
  27. public function theme()
  28. {
  29. return CommonLogic::theme();
  30. }
  31. //微信支付预下单
  32. public function getPrepayId(){
  33. $param = $this->request->only(['type','list'],'post');
  34. $val = Validate::rule([
  35. 'type|购买类型'=>'require|number|in:'.CommonModel::$pay_type_service.','.CommonModel::$pay_type_shopping_good,
  36. 'list|购买列表'=>'require|array|max:100',
  37. ]);
  38. if (!$val->check($param)) throw new ValidateException($val->getError());
  39. $val2 = Validate::rule([
  40. 'id'=>'require|number|gt:0',
  41. 'num|购买数量'=>'require|number|max:99999999',
  42. ]);
  43. foreach ($param['list'] as $list){
  44. if($val2->check($list)) throw new ValidateException($val2->getError());
  45. }
  46. return CommonLogic::getPrepayId($param);
  47. }
  48. }