UserRiceDelivery.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\store\controller\card;
  4. use app\api\service\User as UserService;
  5. use app\common\enum\order\orderGoods\DeliveryStatus as DeliveryStatusEnum;
  6. use app\store\controller\Controller;
  7. use app\store\model\card\UserRiceDelivery as UserRiceDeliveryModel;
  8. use app\store\model\Express as ExpressModel;
  9. use app\store\model\card\UserRiceDeliveryExpress as UserRiceDeliveryExpressModel;
  10. /**
  11. * 米卡兑换配送管理控制器
  12. * Class RiceCard
  13. * @package app\store\controller\card
  14. */
  15. class UserRiceDelivery extends Controller
  16. {
  17. /**
  18. * 米卡兑换配送列表
  19. * @return array
  20. * @throws \think\db\exception\DbException
  21. * @author: zjwhust
  22. * @Time: 2022/1/14 19:22
  23. */
  24. public function list()
  25. {
  26. $model = new UserRiceDeliveryModel;
  27. $list = $model->getList($this->request->param());
  28. return $this->renderSuccess(compact('list'));
  29. }
  30. /**
  31. * 常规发货/拆分发货
  32. * @param int $user_rice_delivery_id 配送ID
  33. * @return array
  34. * @throws \Exception
  35. * @author: zjwhust
  36. * @Time: 2022/1/14 19:24
  37. */
  38. public function delivery(int $user_rice_delivery_id){
  39. $model = UserRiceDeliveryModel::find($user_rice_delivery_id);
  40. if ($model->delivery($this->request->param())) {
  41. return $this->renderSuccess('确认发货成功');
  42. }
  43. return $this->renderError($model->getError());
  44. }
  45. /**
  46. * 修改订单收货信息
  47. * @param int $user_rice_delivery_id 配送ID
  48. * @return array
  49. * @author: zjwhust
  50. * @Time: 2022/1/14 19:24
  51. */
  52. public function updAddress(int $user_rice_delivery_id){
  53. $model = UserRiceDeliveryModel::find($user_rice_delivery_id);
  54. if ($model->updAddress($this->request->param())) {
  55. return $this->renderSuccess('修改收货地址成功');
  56. }
  57. return $this->renderError($model->getError());
  58. }
  59. /**
  60. * 查看物流详情
  61. * @param string $express_no
  62. * @return array
  63. * @throws BaseException
  64. * @throws \think\db\exception\DataNotFoundException
  65. * @throws \think\db\exception\DbException
  66. * @throws \think\db\exception\ModelNotFoundException
  67. * @author: zjwhust
  68. * @Time: 2022/1/14 19:24
  69. */
  70. public function express(string $express_no)
  71. {
  72. $model = new UserRiceDeliveryExpressModel();
  73. $detail = $model->where('express_no',$express_no)->find();
  74. if (!$detail || $detail['delivery_status']!=DeliveryStatusEnum::DELIVERED) {
  75. return $this->renderError('未发货');
  76. }
  77. $res['order'] = [
  78. "express_no" => $detail['express_no'],
  79. "express_company" => $detail['express_company'],
  80. ];
  81. // $res['address'] = UserRiceDeliveryModel::find($detail['user_rice_delivery_id']);
  82. $res['delivery'] = (new ExpressModel)->deliverylist($express_no, $detail['delivery_time'], 1);
  83. return $this->renderSuccess(compact('res'));
  84. }
  85. /**
  86. * 获取拆分包裹的物流列表
  87. * @param int $UserRiceDeliveryId
  88. * @return UserRiceDeliveryExpressModel[]|array|\think\Collection
  89. * @throws \think\db\exception\DataNotFoundException
  90. * @throws \think\db\exception\DbException
  91. * @throws \think\db\exception\ModelNotFoundException
  92. * @author: zjwhust
  93. * @Time: 2022/1/15 11:47
  94. */
  95. public function expressList(int $user_rice_delivery_id){
  96. $list = UserRiceDeliveryExpressModel::where('user_rice_delivery_id',$user_rice_delivery_id)->select();
  97. return $this->renderSuccess(compact('list'));
  98. }
  99. }