123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace addons\shopro\controller\order;
- use addons\shopro\controller\Common;
- use app\admin\model\shopro\order\Express as OrderExpressModel;
- use addons\shopro\library\express\Express as ExpressLib;
- use think\Db;
- //物流
- class Express extends Common
- {
- protected $noNeedLogin = ['push'];
- protected $noNeedRight = ['*'];
- public function index()
- {
- $user = auth_user();
- $order_sn = $this->request->param('order_sn');
- $order_id = Db::name('shopro_order')->where('order_sn',$order_sn)->value('id');
- // 更新包裹信息(5分钟缓存)
- (new ExpressLib)->updateOrderExpress($order_id);
- $expresses = OrderExpressModel::with(['logs'/*, 'items' => function ($query) use ($order_id) {
- return $query->where('order_id', $order_id);
- }*/])->where('user_id', $user->id)->where('order_id', $order_id)->select();
- $address = Db::name('shopro_order_address')->where('order_id',$order_id)->find();
- $items = Db::name('shopro_order_item')->where('order_id',$order_id)->column('goods_image');
- $items = array_domain_image($items);
- $result = [
- 'order_sn' => $order_sn,
- 'address' => $address,
- 'expresses' => $expresses,
- 'goods_image' => $items
- ];
- $this->success('获取成功', $result);
- }
- public function detail()
- {
- $user = auth_user();
- $id = $this->request->param('id');
- $order_id = $this->request->param('order_id');
- // 更新包裹信息(5分钟缓存)
- (new ExpressLib)->updateOrderExpress($order_id);
- $express = OrderExpressModel::with(['logs', 'items' => function ($query) use ($order_id) {
- return $query->where('order_id', $order_id);
- }])->where('user_id', $user->id)->where('order_id', $order_id)->where('id', $id)->find();
- $this->success('获取成功', $express);
- }
- /**
- * 接受物流推送
- *
- * @param Request $request
- * @return void
- */
- public function push()
- {
- //Callback区分 发货寄出 与 退货寄回
- $data = $this->request->param();
- $expressLib = new ExpressLib();
- $result = $expressLib->push($data);
- return response($result, 200, [], 'json');
- }
- }
|