diff --git a/app/common/dao/store/order/StoreOrderOtherDao.php b/app/common/dao/store/order/StoreOrderOtherDao.php index 10269a25..def1eb01 100644 --- a/app/common/dao/store/order/StoreOrderOtherDao.php +++ b/app/common/dao/store/order/StoreOrderOtherDao.php @@ -121,6 +121,9 @@ class StoreOrderOtherDao extends BaseDao ->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) { $query->where('StoreOrderOther.uid', $where['uid']); }) + ->when(isset($where['source']) && $where['source'] !== '', function ($query) use ($where) { + $query->where('StoreOrderOther.source', $where['source']); + }) ->when(isset($where['is_user']) && $where['is_user'] !== 0, function ($query) use ($where) { $query->where(function ($query) { $query->where('order_type', 0)->whereOr(function ($query) { diff --git a/app/controller/admin/store/StoreProduct.php b/app/controller/admin/store/StoreProduct.php index 2255b2ef..bbdf129a 100644 --- a/app/controller/admin/store/StoreProduct.php +++ b/app/controller/admin/store/StoreProduct.php @@ -301,4 +301,12 @@ class StoreProduct extends BaseController $this->repository->updates($ids,$data); return app('json')->success('修改成功'); } + public function copy(){ + $product=$this->repository->getAdminOneProduct(6300,0); + $product = $product->toArray(); + $product['mer_id']=113; + $product['old_product_id']=$product['product_id']; + return $this->repository->create($product, 0,1); + + } } diff --git a/app/controller/api/store/order/StoreProcessing.php b/app/controller/api/store/order/StoreProcessing.php index 31a1a3f9..d0527e1b 100644 --- a/app/controller/api/store/order/StoreProcessing.php +++ b/app/controller/api/store/order/StoreProcessing.php @@ -4,36 +4,49 @@ namespace app\controller\api\store\order; use app\common\model\system\merchant\Merchant; use think\facade\Db; +use crmeb\basic\BaseController; +use think\facade\Log; /** * 订单处理 */ -class StoreOrder extends BaseController +class StoreProcessing extends BaseController { /** * 自动向市级供应链创建订单 */ public function AutomaticallyCreateOrders($order) { - // $merchant = Merchant::find($order['mer_id']); - //添加到代发订单表里 - // 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(); - $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' => 0, - ]; - Db::name('store_order_behalf')->insert($datas); + + + $merchant_two = Db::name('merchant')->where('mer_id', $order['mer_id'])->find(); + $order['uid'] = $merchant_two['uid']; + $order['real_name'] =$merchant_two['mer_name'].'-'. $merchant_two['real_name']; + $order['user_phone'] = $merchant_two['mer_phone']; + $order['user_address'] = $merchant_two['mer_address']; + + $store_group_order = Db::name('store_group_order')->where('group_order_id', $order['group_order_id'])->find(); + $store_group_order_other = Db::name('store_group_order_other')->where('group_order_sn', $order['order_sn'])->find(); + + if (!$store_group_order_other) { + unset($store_group_order['group_order_id']); + $group_order_id=Db::name('store_group_order_other')->insertGetId($store_group_order); + } + $select = Db::name('store_order_product')->where('order_id', $order['order_id'])->select(); + if ($order['source'] == 103 && $select) { + $arr=$select->toArray(); + unset($order['order_id'],$order['orderProduct'],$order['user'],$order['supply_chain_rate'],$order['logistics_code'],$order['logistics_phone']); + $order['group_order_id']=$group_order_id; + $order['mer_id']=$select[0]['product_mer_id']; + $order['source']=104; + $order_id=Db::name('store_order_other')->insertGetId($order); + + foreach ($arr as $key => $value) { + $arr[$key]['order_id'] = $order_id; + $arr[$key]['source'] = 104; + unset($arr[$key]['order_product_id']); + } + Db::name('store_order_product_other')->insertAll($arr); } - // } - // } } } diff --git a/app/controller/merchant/store/order/OrderOther.php b/app/controller/merchant/store/order/OrderOther.php index c2f33406..b40b624d 100644 --- a/app/controller/merchant/store/order/OrderOther.php +++ b/app/controller/merchant/store/order/OrderOther.php @@ -56,9 +56,12 @@ class OrderOther extends BaseController public function lst() { [$page, $limit] = $this->getPage(); - $where = $this->request->params(['status', 'date', 'order_sn', 'username', 'order_type', 'keywords', 'order_id', 'activity_type', 'group_order_sn', 'store_name']); + $where = $this->request->params(['status', 'date', 'order_sn', 'username', 'order_type', 'keywords', 'order_id', 'activity_type', 'group_order_sn', 'store_name','source']); $where['mer_id'] = $this->request->merId(); $where['paid']=1; + if($where['source']<=0){ + $where['source']=105; + } return app('json')->success($this->repository->merchantGetList($where, $page, $limit)); } diff --git a/app/controller/merchant/store/order/StoreOrderBehalf.php b/app/controller/merchant/store/order/StoreOrderBehalf.php index 5a6c3953..2c00ea7c 100644 --- a/app/controller/merchant/store/order/StoreOrderBehalf.php +++ b/app/controller/merchant/store/order/StoreOrderBehalf.php @@ -76,7 +76,7 @@ class StoreOrderBehalf extends BaseController if ($column) { $where['order_id'] = $column; }else{ - return app('json')->success([]); + return app('json')->success(['list'=>[],'count'=>0]); } if ($status == 0) { $where['status'] = 2; @@ -128,23 +128,24 @@ class StoreOrderBehalf extends BaseController /** * 状态 */ - public function status($id) + public function status() { $mer_id = $this->request->merId(); $status = $this->request->param('status'); + $id = $this->request->param('id'); $type_id = Db::name('merchant')->where('mer_id', $mer_id)->value('type_id'); $type_code = Db::name('merchant_type')->where('mer_type_id', $type_id)->value('type_code'); $res=0; if ($status == 1) { if($type_code=='TypeSupplyChain'){ $res = Db::name('store_order_behalf')->where('product_mer_id', $mer_id) - ->where('id',$id)->where('status',0)->update(['status'=>1]); + ->where('order_id',$id)->where('status',0)->update(['status'=>1]); } } if ($status == 3) { if($type_code!='TypeSupplyChain'){ $res = Db::name('store_order_behalf')->where('master_mer_id', $mer_id) - ->where('id',$id)->where('status',1)->update(['status'=>3]); + ->where('order_id',$id)->where('status',1)->update(['status'=>3]); } } if($res){ @@ -153,4 +154,28 @@ class StoreOrderBehalf extends BaseController return app('json')->fail('设置失败'); } } + /** + * TODO 订单头部统计 + * @return mixed + * @author Qinii + * @day 2020-08-17 + */ + public function Chart() + { + $mer_id= $this->request->merId(); + $type_id = Db::name('merchant')->where('mer_id', $mer_id)->value('type_id'); + $type_code = Db::name('merchant_type')->where('mer_type_id', $type_id)->value('type_code'); + if($type_code=='TypeSupplyChain'){ + $column = Db::name('store_order_behalf')->where('product_mer_id', $mer_id)->column('order_id'); + }else{ + $column = Db::name('store_order_behalf')->where('master_mer_id', $mer_id)->column('order_id'); + } + $where=[]; + if ($column) { + $where['order_id'] = $column; + }else{ + return app('json')->success(['list'=>[],'count'=>0]); + } + return app('json')->success($this->repository->OrderTitleNumberWhere($mer_id, $where)); + } } diff --git a/app/listener/paySuccess.php b/app/listener/paySuccess.php index be296e8c..fa8e4fb7 100644 --- a/app/listener/paySuccess.php +++ b/app/listener/paySuccess.php @@ -15,6 +15,7 @@ use app\common\repositories\system\merchant\MerchantRepository; use crmeb\utils\DingTalk; use think\facade\Db; use think\facade\Log; +use app\controller\api\store\order\StoreProcessing; /** * 支付后逻辑 @@ -30,14 +31,15 @@ class paySuccess public $index = 1; public $remain; - public function handle($event) + public function handle($event,StoreProcessing $StoreProcessing) { try { $orderList = $event['groupOrder']['orderList']; $storeConsumptionUserDao = new StoreConsumptionUserDao(); $storeConsumptionUserDao->check($event['groupOrder']['uid'], $event['groupOrder']['group_order_id']); foreach ($orderList as $k => $order) { - + // + $StoreProcessing->AutomaticallyCreateOrders($order); $this->recordOrderAddr($order); } } catch (\Exception $e) { diff --git a/route/admin/product.php b/route/admin/product.php index 27f7c245..097707f7 100644 --- a/route/admin/product.php +++ b/route/admin/product.php @@ -186,6 +186,7 @@ Route::group(function () { Route::get('detail/:id', '/detail')->name('systemStoreProductDetail')->option([ '_alias' => '详情', ]); + Route::get('copy', '/copy'); Route::post('update/:id', '/update')->name('systemStoreProductUpdate')->option([ '_alias' => '编辑', ]); diff --git a/route/merchant/order.php b/route/merchant/order.php index c802363c..4ed6f0fc 100644 --- a/route/merchant/order.php +++ b/route/merchant/order.php @@ -323,6 +323,7 @@ Route::group(function () { //代发货订单 Route::group('store/behalf_admin', function () { Route::get('/order_list', '/lst'); + Route::get('/chart', '/chart'); Route::get('/code', '/logisticsCode'); Route::get('/number', '/number'); Route::post('/status', '/status');