diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 17bcd32a..1171823c 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -1064,9 +1064,9 @@ class StoreOrderCreateRepository extends StoreOrderRepository $product_source_id=0; $product_mer_id=0; if($cart['source']==103){ - $old_product_id=Db::name('product')->where('product_id',$cart['product_id'])->value('old_product_id'); + $old_product_id=Db::name('store_product')->where('product_id',$cart['product_id'])->value('old_product_id'); if($old_product_id){ - $old_mer_id=Db::name('product')->where('product_id',$old_product_id)->value('mer_id'); + $old_mer_id=Db::name('store_product')->where('product_id',$old_product_id)->value('mer_id'); $product_mer_id=$old_mer_id; $product_source_id=$old_product_id; } diff --git a/app/controller/admin/order/StoreOrderBehalf.php b/app/controller/admin/order/StoreOrderBehalf.php new file mode 100644 index 00000000..7085ed05 --- /dev/null +++ b/app/controller/admin/order/StoreOrderBehalf.php @@ -0,0 +1,122 @@ + +// +---------------------------------------------------------------------- + + +namespace app\controller\admin\store\order; + + + +use crmeb\basic\BaseController; + +use app\common\repositories\store\order\StoreOrderRepository; +use think\facade\Db; +use think\App; +use app\common\dao\store\order\StoreOrderDao; + +/**代发订单 + * Class StoreOrder + * @package app\controller\api\store\order + * @author xaboy + * @day 2020/6/10 + */ +class StoreOrderBehalf extends BaseController +{ + /** + * @var StoreOrderRepository + */ + protected $repository; + protected $dao; + + /** + * StoreOrder constructor. + * @param App $app + * @param StoreOrderRepository $repository + */ + public function __construct(App $app, StoreOrderRepository $repository,StoreOrderDao $dao) + { + parent::__construct($app); + $this->repository = $repository; + $this->dao = $dao; + } + /** + * @return mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author xaboy + * @day 2020/6/10 + */ + public function lst() + { + [$page, $limit] = $this->getPage(); + $status = $this->request->param('status','all'); + $mer_id = $this->request->merId(); + if ($mer_id) { + if($status=='all'){ + $where['status']=['>=',0]; + }else{ + $where['status']=['=',$status]; + } + $column = Db::name('store_order_behalf')->where('mer_id', $mer_id)->where($where)->page($page)->limit($limit)->column('order_id'); + if ($column) { + $where['order_id'] = $column; + + } + if ($status == 0) { + $where['status'] = 2; + } elseif ($status == 1) { + $where['status'] = 3; + } + $where['source']=103; + return app('json')->success($this->repository->getList($where,1, $limit)); + + } + return app('json')->success([]); + } + + /** + * @param $id + * @return mixed + * @author xaboy + * @day 2020/6/10 + */ + public function detail($id) + { + $order = $this->repository->getDetail((int)$id); + if (!$order) + return app('json')->fail('订单不存在'); + if ($order->order_type == 1) { + $order->append(['take', 'refund_status']); + } + return app('json')->success($order->toArray()); + } + + /**代发订单统计 + * @return mixed + * @author xaboy + * @day 2020/6/10 + */ + public function number() + { + $mer_id=$this->request->merId(); + if ($mer_id) { + $noPostage = Db::name('store_order_behalf') + ->where('mer_id', $mer_id)->where('status',0) + ->count(); + $noDeliver = Db::name('store_order_behalf') + ->where('mer_id', $mer_id)->where('status',1) + ->count(); + + } + return app('json')->success(compact('noDeliver', 'noPostage',)); + } +} diff --git a/app/controller/api/store/order/StoreOrderBehalf.php b/app/controller/api/store/order/StoreOrderBehalf.php index 7cc33d66..08b25bd5 100644 --- a/app/controller/api/store/order/StoreOrderBehalf.php +++ b/app/controller/api/store/order/StoreOrderBehalf.php @@ -77,18 +77,18 @@ class StoreOrderBehalf extends BaseController }else{ $where['status']=['=',$status]; } - // $column = Db::name('store_order_behalf')->where('mer_id', $mer_id)->where($where)->page($page)->limit($limit)->column('order_id'); - // if ($column) { - // $where['order_id'] = $column; + $column = Db::name('store_order_behalf')->where('mer_id', $mer_id)->where($where)->page($page)->limit($limit)->column('order_id'); + if ($column) { + $where['order_id'] = $column; - // } + } if ($status == 0) { $where['status'] = 2; } elseif ($status == 1) { $where['status'] = 3; } $where['source']=103; - return app('json')->success($this->repository->getList($where, $page, $limit)); + return app('json')->success($this->repository->getList($where,1, $limit)); } return app('json')->success([]); diff --git a/app/controller/api/store/order/StoreProcessing.php b/app/controller/api/store/order/StoreProcessing.php index 87551f36..6edda2ca 100644 --- a/app/controller/api/store/order/StoreProcessing.php +++ b/app/controller/api/store/order/StoreProcessing.php @@ -20,16 +20,19 @@ class StoreOrder extends BaseController // if ($merchant['type_id'] == Merchant::TypeSupplyChain) { // $codes = explode(',', $order['user_address_code']); // if (count($codes) > 4) { - // $merchant_two = Db::name('merchant')->where('street_id', $codes[3])->where('type_id', 17)->where('category_id', $merchant['category_id'])->find(); - if ($order['source']==103) { - $datas = [ - 'master_mer_id' => $order['mer_id'], - 'mer_id' => $merchant_two['mer_id'], - 'order_id' => $order['order_id'], - 'status' => 0 - ]; - Db::name('store_order_behalf')->insert($datas); - } + // $merchant_two = Db::name('merchant')->where('street_id', $codes[3])->where('type_id', 17)->where('category_id', $merchant['category_id'])->find(); + $find = Db::name('store_order_product')->where('order_id', $order['order_id'])->field('product_source_id,product_mer_id'); + if ($order['source'] == 103 && $find) { + $datas = [ + 'master_mer_id' => $order['mer_id'], + 'product_mer_id' => $find['product_mer_id'], + 'product_source_id' => $find['product_source_id'], + 'order_id' => $order['order_id'], + 'delivery' => 0, + 'status' => 1, + ]; + Db::name('store_order_behalf')->insert($datas); + } // } // } }