123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- declare (strict_types = 1);
- namespace app\store\controller\card;
- use app\api\service\User as UserService;
- use app\common\enum\order\orderGoods\DeliveryStatus as DeliveryStatusEnum;
- use app\store\controller\Controller;
- use app\store\model\card\UserRiceDelivery as UserRiceDeliveryModel;
- use app\store\model\Express as ExpressModel;
- use app\store\model\card\UserRiceDeliveryExpress as UserRiceDeliveryExpressModel;
- /**
- * 米卡兑换配送管理控制器
- * Class RiceCard
- * @package app\store\controller\card
- */
- class UserRiceDelivery extends Controller
- {
- /**
- * 米卡兑换配送列表
- * @return array
- * @throws \think\db\exception\DbException
- * @author: zjwhust
- * @Time: 2022/1/14 19:22
- */
- public function list()
- {
- $model = new UserRiceDeliveryModel;
- $list = $model->getList($this->request->param());
- return $this->renderSuccess(compact('list'));
- }
- /**
- * 常规发货/拆分发货
- * @param int $user_rice_delivery_id 配送ID
- * @return array
- * @throws \Exception
- * @author: zjwhust
- * @Time: 2022/1/14 19:24
- */
- public function delivery(int $user_rice_delivery_id){
- $model = UserRiceDeliveryModel::find($user_rice_delivery_id);
- if ($model->delivery($this->request->param())) {
- return $this->renderSuccess('确认发货成功');
- }
- return $this->renderError($model->getError());
- }
- /**
- * 修改订单收货信息
- * @param int $user_rice_delivery_id 配送ID
- * @return array
- * @author: zjwhust
- * @Time: 2022/1/14 19:24
- */
- public function updAddress(int $user_rice_delivery_id){
- $model = UserRiceDeliveryModel::find($user_rice_delivery_id);
- if ($model->updAddress($this->request->param())) {
- return $this->renderSuccess('修改收货地址成功');
- }
- return $this->renderError($model->getError());
- }
- /**
- * 查看物流详情
- * @param string $express_no
- * @return array
- * @throws BaseException
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @author: zjwhust
- * @Time: 2022/1/14 19:24
- */
- public function express(string $express_no)
- {
- $model = new UserRiceDeliveryExpressModel();
- $detail = $model->where('express_no',$express_no)->find();
- if (!$detail || $detail['delivery_status']!=DeliveryStatusEnum::DELIVERED) {
- return $this->renderError('未发货');
- }
- $res['order'] = [
- "express_no" => $detail['express_no'],
- "express_company" => $detail['express_company'],
- ];
- // $res['address'] = UserRiceDeliveryModel::find($detail['user_rice_delivery_id']);
- $res['delivery'] = (new ExpressModel)->deliverylist($express_no, $detail['delivery_time'], 1);
- return $this->renderSuccess(compact('res'));
- }
- /**
- * 获取拆分包裹的物流列表
- * @param int $UserRiceDeliveryId
- * @return UserRiceDeliveryExpressModel[]|array|\think\Collection
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- * @author: zjwhust
- * @Time: 2022/1/15 11:47
- */
- public function expressList(int $user_rice_delivery_id){
- $list = UserRiceDeliveryExpressModel::where('user_rice_delivery_id',$user_rice_delivery_id)->select();
- return $this->renderSuccess(compact('list'));
- }
- }
|