diff --git a/app/common/dao/store/order/StoreGroupOrderDao.php b/app/common/dao/store/order/StoreGroupOrderDao.php index 5826df98..f3253527 100644 --- a/app/common/dao/store/order/StoreGroupOrderDao.php +++ b/app/common/dao/store/order/StoreGroupOrderDao.php @@ -42,11 +42,15 @@ class StoreGroupOrderDao extends BaseDao * @author xaboy * @day 2020/6/11 */ - public function orderNumber($uid = null) + public function orderNumber($uid = null,$is_virtual=0) { + $where = ['is_del' => 0, 'paid' => 0]; + if ($is_virtual>=98){ + $where['is_virtual'] = $is_virtual; + } return StoreGroupOrder::when($uid, function ($query, $uid) { $query->where('uid', $uid); - })->where('is_del', 0)->where('paid', 0)->count(); + })->where($where)->count(); } /** diff --git a/app/common/model/system/merchant/Merchant.php b/app/common/model/system/merchant/Merchant.php index bdf1ecbc..e3f41df3 100644 --- a/app/common/model/system/merchant/Merchant.php +++ b/app/common/model/system/merchant/Merchant.php @@ -184,6 +184,10 @@ class Merchant extends BaseModel return $this->merchantType()->bind(['type_name']); } + public function categoryName() + { + return $this->merchantCategory()->bind(['category_name']); + } /** * 供应链中间件 * diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 4d652f22..ee0dce07 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -973,6 +973,10 @@ class StoreOrderCreateRepository extends StoreOrderRepository $cartIds = []; $orderList = []; $user_address = isset($address) ? ($address['province'] . $address['city'] . $address['district'] . $address['street'] . $address['detail']) : ''; + $is_virtual=$order_model ? 1 : 0; + if ($product_type!=0){ + $is_virtual=$product_type; + } // 验证下单来源,如果是普通来源,则执行分销推广佣金分配 if($source == 2) // 普通商品 { @@ -1093,10 +1097,6 @@ class StoreOrderCreateRepository extends StoreOrderRepository $rate = bcmul($merchantCart['merchantCategory']['commission_rate'], 100, 4); } - $is_virtual=$order_model ? 1 : 0; - if ($product_type!=0){ - $is_virtual=$product_type; - } //整理订单数据 $_order = [ 'cartInfo' => $merchantCart, @@ -1235,6 +1235,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository $groupOrder = [ 'uid' => $uid, 'group_order_sn' => count($orderList) === 1 ? $orderList[0]['order_sn'] : ($this->getNewOrderId() . '0'), + 'is_virtual' => $order_model ? 1 : 0, 'total_postage' => $totalPostage, 'total_price' => $orderInfo['total_price'], 'total_num' => $totalNum, diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index 74218251..845ff36e 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -581,30 +581,39 @@ class StoreOrderRepository extends BaseRepository * @author xaboy * @day 2020/6/10 */ - public function userOrderNumber(int $uid, $source = 2) + public function userOrderNumber(int $uid, $source = 2,$product_type=0) { - $noPay = app()->make(StoreGroupOrderRepository::class)->orderNumber($uid); - + $noPay = app()->make(StoreGroupOrderRepository::class)->orderNumber($uid,$product_type); + $where = [ + 'StoreOrder.is_del' => 0, + 'source' => $source + ]; + $where3=['uid' => $uid, 'status' => [0, 1, 2]]; + if ($product_type>98){ + $where['is_virtual'] = $product_type; + $where3['is_virtual'] = $product_type; + } $noPostage = $this->dao->search(['uid' => $uid, 'status' => 0, 'paid' => 1]) - ->where('StoreOrder.is_del', 0) - ->where('source', $source) + ->where($where) ->count(); $all = $this->dao->search(['uid' => $uid, 'status' => -2]) - ->where('source', $source) - ->where('StoreOrder.is_del', 0) + ->where($where) ->count(); - $noDeliver = $this->dao->search(['uid' => $uid, 'status' => 1, 'paid' => 1])->where('StoreOrder.is_del', 0)->count(); $noComment = $this->dao->search(['uid' => $uid, 'status' => 2, 'paid' => 1]) - ->where('source', $source) - ->where('StoreOrder.is_del', 0) + ->where($where) ->count(); - $done = $this->dao->search(['uid' => $uid, 'status' => 3, 'paid' => 1])->where('StoreOrder.is_del', 0)->count(); - $refund = app()->make(StoreRefundOrderRepository::class)->getWhereCount(['uid' => $uid, 'status' => [0, 1, 2]]); - $orderPrice = $this->dao->search(['uid' => $uid, 'paid' => 1])->where('source', $source)->sum('pay_price'); + $where2=$where; + unset($where2['source']); + $noDeliver = $this->dao->search(['uid' => $uid, 'status' => 1, 'paid' => 1])->where($where2)->count(); + $done = $this->dao->search(['uid' => $uid, 'status' => 3, 'paid' => 1])->where($where2)->count(); + + $refund = app()->make(StoreRefundOrderRepository::class)->getWhereCount($where3); + unset($where['StoreOrder.is_del']); + $orderPrice = $this->dao->search(['uid' => $uid, 'paid' => 1])->where($where)->sum('pay_price'); $orderCount = $this->dao->search(['uid' => $uid, 'paid' => 1]) - ->where('source', $source) + ->where($where) ->count(); return compact('noComment', 'orderPrice', 'done', 'refund', 'noDeliver', 'noPay', 'noPostage', 'orderCount', 'all'); } @@ -835,13 +844,14 @@ class StoreOrderRepository extends BaseRepository * @param int|null $orderType * @return array */ - public function OrderTitleNumber(?int $merId, ?int $orderType) + public function OrderTitleNumber(?int $merId, ?int $orderType, ?int $product_type=0) { $where = []; $sysDel = $merId ? 0 : null; //商户删除 if ($merId) $where['mer_id'] = $merId; //商户订单 if ($orderType === 0) $where['order_type'] = 0; //普通订单 if ($orderType === 1) $where['take_order'] = 1; //已核销订单 + if ($product_type!=0) $where['product_type'] = $product_type; //商品属性 //1: 未支付 2: 未发货 3: 待收货 4: 待评价 5: 交易完成 6: 已退款 7: 已删除 $all = $this->dao->search($where, $sysDel)->where($this->getOrderType(0))->count(); $statusAll = $all; @@ -2314,16 +2324,21 @@ class StoreOrderRepository extends BaseRepository if (!$data) return; unset($data[0]); $mer_cate_id=Db::name('store_category')->where('mer_id',$merId)->where('cate_name','默认分类')->value('store_category_id'); - if ($mer_cate_id==0){ - $mer_cate=['pid'=>0,'/']; - Db::name('store_category')->insert(); + if (!$mer_cate_id ||$mer_cate_id==0){ + $mer_cate=['pid'=>0,'cate_name'=>'默认分类','path'=>'/','mer_id'=>$merId,'sort'=>0,'is_show'=>1,'create_time'=>date('Y-m-d H:i:s')]; + $mer_cate_id=Db::name('store_category')->insertGetId($mer_cate); + $mer_cate['pid']=$mer_cate_id; + $mer_cate['path']='/'.$mer_cate_id.'/'; + $mer_cate['level']=1; + $mer_cate_id=Db::name('store_category')->insertGetId($mer_cate); } + $make = app()->make(ProductRepository::class); foreach ($data as $datum) { $find=Db::name('store_product')->where('mer_id', $merId)->where('bar_code', $datum['where']['bar_code'])->find(); if ($find){ Db::name('store_product')->where('product_id', $find['product_id'])->update($datum['value']); }else{ - $store_category_id=Db::name('store_category')->where('mer_id',0)->where('cate_name',$datum['value']['cate_name'])->value('store_category_id'); + $store_category_id=Db::name('store_category')->where('mer_id',0)->where('cate_name',$datum['value']['cate_id'])->value('store_category_id'); $datas = [ "image" => "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/03d76202301101051502568.png", "slider_image" => [ @@ -2338,6 +2353,7 @@ class StoreOrderRepository extends BaseRepository "mer_cate_id" => [ 0 => $mer_cate_id//要修改 ], + 'product_type'=>98, "unit_name" => $datum['value']['unit_name'], "sort" => 0, "is_show" => "", @@ -2375,7 +2391,7 @@ class StoreOrderRepository extends BaseRepository ], ], "give_coupon_ids" => [], - "type" => 50,//供应链商品 + "type" => 0,//供应链商品 "svip_price" => 0, "svip_price_type" => 0, "params" => [], @@ -2384,11 +2400,10 @@ class StoreOrderRepository extends BaseRepository "mer_status" => 1, "rate" => 3, ]; - $datum['value']['mer_id']=$merId; - Db::name('store_product')->insert($datum['value']); + $make->create($datas,98); } } - halt($data); + halt(22); $import_id = $arrary['import_id']; Db::transaction(function () use ($data, $merId, $import_id) { $result = []; diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index f10dd81c..e556955c 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -45,6 +45,7 @@ use app\common\dao\store\product\ProductDao as dao; use app\common\repositories\store\StoreCategoryRepository; use app\common\repositories\store\shipping\ShippingTemplateRepository; use app\common\repositories\store\StoreBrandRepository; +use think\facade\Log; use think\facade\Queue; use think\facade\Route; use think\contract\Arrayable; @@ -621,7 +622,10 @@ class ProductRepository extends BaseRepository */ public function setUnique(int $id, $sku, int $type) { - return $unique = substr(md5($sku . $id), 12, 11) . $type; + $str = strval($type); + $result=strlen($str); + $length=12-$result; + return $unique = substr(md5($sku . $id), 12, $length) . $type; // $has = (app()->make(ProductAttrValueRepository::class))->merUniqueExists(null, $unique); // return $has ? false : $unique; } diff --git a/app/common/repositories/system/merchant/MerchantRepository.php b/app/common/repositories/system/merchant/MerchantRepository.php index 155b92a4..7ee0d434 100644 --- a/app/common/repositories/system/merchant/MerchantRepository.php +++ b/app/common/repositories/system/merchant/MerchantRepository.php @@ -274,7 +274,7 @@ class MerchantRepository extends BaseRepository */ public function getList($where, $page, $limit, $userInfo) { - $field = 'care_count,is_trader,type_id,mer_id,mer_banner,mini_banner,mer_name, mark,mer_avatar,product_score,service_score,postage_score,sales,status,is_best,create_time,long,lat,mer_info,mer_keyword'; + $field = 'category_id,care_count,is_trader,type_id,mer_id,mer_banner,mini_banner,mer_name, mark,mer_avatar,product_score,service_score,postage_score,sales,status,is_best,create_time,long,lat,mer_info,mer_keyword'; $where['status'] = 1; $where['mer_state'] = 1; $where['is_del'] = 0; @@ -293,7 +293,7 @@ class MerchantRepository extends BaseRepository if ($where['keyword'] !== '') { app()->make(UserVisitRepository::class)->searchMerchant($userInfo ? $userInfo['uid'] : 0, $where['keyword']); } - $query = $this->dao->search($where)->with(['type_name']); + $query = $this->dao->search($where)->with(['type_name','category_name']); $count = $query->count(); $status = systemConfig('mer_location'); $list = $query->page($page, $limit)->setOption('field', [])->field($field)->select() diff --git a/app/controller/api/server/StoreOrder.php b/app/controller/api/server/StoreOrder.php index d2e71c13..a37acbf1 100644 --- a/app/controller/api/server/StoreOrder.php +++ b/app/controller/api/server/StoreOrder.php @@ -35,7 +35,9 @@ class StoreOrder extends BaseController public function orderStatistics($merId, StoreOrderRepository $repository) { - $order = $repository->OrderTitleNumber($merId, null); + + $product_type=$this->request->param('product_type',0); + $order = $repository->OrderTitleNumber($merId, null,$product_type); $order['refund'] = app()->make(StoreRefundOrderRepository::class)->getWhereCount(['is_system_del' => 0, 'mer_id' => $merId]); $common = app()->make(Common::class); $data = []; diff --git a/app/controller/api/store/order/StoreOrder.php b/app/controller/api/store/order/StoreOrder.php index cb3390ce..c9bdc055 100644 --- a/app/controller/api/store/order/StoreOrder.php +++ b/app/controller/api/store/order/StoreOrder.php @@ -188,9 +188,10 @@ class StoreOrder extends BaseController public function number() { $source = $this->request->param('source'); + $product_type = $this->request->param('product_type',0); $source = !isset($source)?2:$source; // 默认来源为2 普通商品订单 // return app('json')->success(['orderPrice' => $this->request->userInfo()->pay_price] + $this->repository->userOrderNumber($this->request->uid(), $source)); - return app('json')->success($this->repository->userOrderNumber($this->request->uid(), $source)); + return app('json')->success($this->repository->userOrderNumber($this->request->uid(), $source,$product_type)); } /**