Order.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\mobile\controller;
  3. use app\BaseController;
  4. use app\mobile\logic\OrderLogic;
  5. use app\model\MasterOrderModel;
  6. use think\exception\ValidateException;
  7. use think\facade\Validate;
  8. //【订单】
  9. class Order extends BaseController
  10. {
  11. //下单
  12. public function add()
  13. {
  14. $param = $this->request->only(['type', 'list', 'addr_id', 'remark' => ''], 'post');
  15. $val = Validate::rule([
  16. 'type|购买类型' => 'require|number|in:' . MasterOrderModel::$type_exchange_good . ',' . MasterOrderModel::$type_shopping_good . ',' . MasterOrderModel::$type_service,
  17. 'list|购买列表' => 'require|array|max:100',
  18. 'addr_id|收货地址' => 'require|number|gt:0',
  19. 'remark|备注' => 'max:255'
  20. ]);
  21. if (!$val->check($param)) throw new ValidateException($val->getError());
  22. $val2 = Validate::rule([
  23. 'id' => 'require|number|gt:0',
  24. 'num|购买数量' => 'require|number|max:99999999',
  25. ]);
  26. foreach ($param['list'] as $list) {
  27. if (!$val2->check($list)) throw new ValidateException($val2->getError());
  28. }
  29. return OrderLogic::add($param);
  30. }
  31. //订单列表
  32. public function list()
  33. {
  34. $param = $this->request->only(['page' => 1, 'size' => 10, 'status' => ''], 'post');
  35. return OrderLogic::list($param);
  36. }
  37. //订单详情
  38. public function info()
  39. {
  40. $id = $this->request->post('id/d', 0);
  41. return OrderLogic::info($id);
  42. }
  43. //查看物流信息
  44. public function express(){
  45. $post_code = $this->request->post('post_code','');
  46. return OrderLogic::express($post_code);
  47. }
  48. }