diff --git a/app/admin/lists/store_order/StoreOrderLists.php b/app/admin/lists/store_order/StoreOrderLists.php index 7ba04fd0b..39c010c45 100644 --- a/app/admin/lists/store_order/StoreOrderLists.php +++ b/app/admin/lists/store_order/StoreOrderLists.php @@ -80,8 +80,8 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface $product = StoreOrderCartInfo::where('oid', $item['id'])->field(['id', 'oid', 'product_id', 'cart_info']) ->limit(3)->select(); foreach ($product as &$items) { - $items['store_name'] = $items['cart_info']['name']; - $items['image'] = $items['cart_info']['image']; + $items['store_name'] = $items['cart_info']['name']??''; + $items['image'] = $items['cart_info']['image']??''; } $item['product'] = $product; return $item; diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index bcecea565..1220fab27 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -127,6 +127,33 @@ class StoreProductLogic extends BaseLogic } } + /* + * 传入三级或者二级分类返还上级分类 一级那全是相同 + */ + public static function dealChangeCate($cate_id) + { + $value =[]; + $last_cate = Db::name('store_category')->where('id',$cate_id)->value('pid'); + if(!empty($last_cate)){ + //2 + $value['two_cate_id'] = $last_cate; + //1 + $first_cate = Db::name('store_category')->where('id',$value['two_cate_id'])->value('pid'); + if(empty($first_cate)){//顶级了 + $value['two_cate_id'] = $cate_id; + $value['top_cate_id'] = $last_cate; + }else{ + $value['top_cate_id'] = $first_cate; + } + + }else{ + //1-2 选的1级目录 + $value['two_cate_id'] = $cate_id; + $value['top_cate_id'] = $cate_id; + } + return $value; + } + /** * @notes 编辑商品列表 * @param array $params @@ -175,15 +202,15 @@ class StoreProductLogic extends BaseLogic self::updateGoodsclass($params['cate_id'], $value['store_id']); } }*/ - - + $dealCate = self::dealChangeCate($params['cate_id']); //修改 StoreBranchProduct::where('product_id', $params['id'])->update([ 'price' => $params['price'], 'vip_price' => $params['vip_price'], 'cost' => $params['cost'],'unit'=>$params['unit'], 'batch'=>$params['batch'],'store_name'=>$params['store_name'], 'manufacturer_information' => $params['manufacturer_information']??'', - 'store_info' => $params['store_info']??'', + 'store_info' => $params['store_info']??'','cate_id'=>$params['cate_id'], + 'top_cate_id'=>$dealCate['top_cate_id'],'two_cate_id'=>$dealCate['two_cate_id'] ]); Db::commit(); @@ -283,6 +310,7 @@ class StoreProductLogic extends BaseLogic $attr_value = StoreProductAttrValue::where('product_id', $id)->findOrEmpty(); Db::startTrans(); try { + $dealCate = self::dealChangeCate($find['cate_id']); $product = [ 'product_id' => $find['id'], 'image' => $find['image'], @@ -291,6 +319,8 @@ class StoreProductLogic extends BaseLogic 'keyword' => $find['keyword'], 'bar_code' => $find['bar_code'], 'cate_id' => $find['cate_id'], + 'top_cate_id' => $dealCate['top_cate_id'], + 'two_cate_id' => $dealCate['two_cate_id'], 'price' => $find['price'], 'unit' => $find['unit'], 'store_id' => $store_id, diff --git a/app/queue/redis/StoreStorageSend.php b/app/queue/redis/StoreStorageSend.php index 02e7eefe6..04f5ad9ba 100644 --- a/app/queue/redis/StoreStorageSend.php +++ b/app/queue/redis/StoreStorageSend.php @@ -46,6 +46,7 @@ class StoreStorageSend implements Consumer $attr_value = StoreProductAttrValue::where('product_id', $product_arr['id'])->findOrEmpty(); Db::startTrans(); try { + $dealCate = self::dealChangeCate($find['cate_id']); $product = [ 'product_id' => $find['id'], 'image' => $find['image'], @@ -54,6 +55,8 @@ class StoreStorageSend implements Consumer 'keyword' => $find['keyword'], 'bar_code' => $find['bar_code'], 'cate_id' => $find['cate_id'], + 'top_cate_id' => $dealCate['top_cate_id'], + 'two_cate_id' => $dealCate['two_cate_id'], 'price' => $find['price'], // 'cost' => $find['cost'], //v1.0 'cost' => $find['cost'], @@ -179,4 +182,31 @@ class StoreStorageSend implements Consumer Log::error('store-storage队列消费失败: ' . $e->getMessage() . ',line:' . $e->getLine() . ',file:' . $e->getFile()); return $package; } + + /* + * 传入三级或者二级分类返还上级分类 一级那全是相同 + */ + public static function dealChangeCate($cate_id) + { + $value =[]; + $last_cate = Db::name('store_category')->where('id',$cate_id)->value('pid'); + if(!empty($last_cate)){ + //2 + $value['two_cate_id'] = $last_cate; + //1 + $first_cate = Db::name('store_category')->where('id',$value['two_cate_id'])->value('pid'); + if(empty($first_cate)){//顶级了 + $value['two_cate_id'] = $cate_id; + $value['top_cate_id'] = $last_cate; + }else{ + $value['top_cate_id'] = $first_cate; + } + + }else{ + //1-2 选的1级目录 + $value['two_cate_id'] = $cate_id; + $value['top_cate_id'] = $cate_id; + } + return $value; + } } diff --git a/app/statistics/logic/OrderLogic.php b/app/statistics/logic/OrderLogic.php index 3f1617ac7..274653768 100644 --- a/app/statistics/logic/OrderLogic.php +++ b/app/statistics/logic/OrderLogic.php @@ -67,6 +67,18 @@ class OrderLogic extends BaseLogic return bcadd($todayAmount, $pay_price, 2); } + public static function dealFlexiblePrice($where,$start,$end) + { + $todayAmount = UserRecharge::where($where) + ->whereBetweenTime('create_time', $start, $end) + ->sum('price'); + $pay_price = StoreOrder::where($where) + ->whereBetweenTime('create_time', $start, $end) + ->sum('pay_price'); + return bcadd($todayAmount, $pay_price, 2); + + } + public static function sales($where,$time){ $select=StoreOrder::where($where)->whereDay('create_time',$time)->limit(10)->order('id desc')->field('id,order_id,pay_price,create_time')->select(); return $select?->toArray(); diff --git a/app/store/logic/WorkbenchLogic.php b/app/store/logic/WorkbenchLogic.php index 72431a400..748df2080 100644 --- a/app/store/logic/WorkbenchLogic.php +++ b/app/store/logic/WorkbenchLogic.php @@ -84,7 +84,8 @@ class WorkbenchLogic extends BaseLogic $data['income_amount'] = StoreFinanceFlow::where($storeFinanceWhere)->whereBetweenTime('create_time', $startTime, $endTime)->sum('number'); //门店收款金额 $all_where['paid'] = 1; - $data['receipt_amount'] = OrderLogic::dayPayPrice($all_where,date('Y-m-d',time())); +// $data['receipt_amount'] = OrderLogic::dayPayPrice($all_where,date('Y-m-d',time())); + $data['receipt_amount'] = OrderLogic::dealFlexiblePrice($all_where,$startTime,$endTime); // $data['receipt_amount'] = UserRecharge::where($userRechargeWhere)->whereBetweenTime('create_time', $startTime, $endTime)->sum('price'); //保证金金额 $data['deposit_amount'] = StoreFinanceFlow::where($storeFinanceWhereTwo)->whereBetweenTime('create_time', $startTime, $endTime)->sum('number');