123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace app\mobile\controller;
- use app\BaseController;
- use app\mobile\logic\OrderLogic;
- use app\model\MasterOrderModel;
- use think\exception\ValidateException;
- use think\facade\Validate;
- //【订单】
- class Order extends BaseController
- {
- //下单
- public function add()
- {
- $param = $this->request->only(['type', 'list', 'addr_id', 'remark' => ''], 'post');
- $val = Validate::rule([
- 'type|购买类型' => 'require|number|in:' . MasterOrderModel::$type_exchange_good . ',' . MasterOrderModel::$type_shopping_good . ',' . MasterOrderModel::$type_service,
- 'list|购买列表' => 'require|array|max:100',
- 'addr_id|收货地址' => 'require|number|gt:0',
- 'remark|备注' => 'max:255'
- ]);
- if (!$val->check($param)) throw new ValidateException($val->getError());
- $val2 = Validate::rule([
- 'id' => 'require|number|gt:0',
- 'num|购买数量' => 'require|number|max:99999999',
- ]);
- foreach ($param['list'] as $list) {
- if (!$val2->check($list)) throw new ValidateException($val2->getError());
- }
- return OrderLogic::add($param);
- }
- //订单列表
- public function list()
- {
- $param = $this->request->only(['page' => 1, 'size' => 10, 'status' => ''], 'post');
- return OrderLogic::list($param);
- }
- //订单详情
- public function info()
- {
- $id = $this->request->post('id/d', 0);
- return OrderLogic::info($id);
- }
- //查看物流信息
- public function express(){
- $post_code = $this->request->post('post_code','');
- return OrderLogic::express($post_code);
- }
- }
|