diff --git a/.gitignore b/.gitignore index ee1734d9..a0a855bf 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ /tests/tmp /tests/.phpunit.result.cache public/uploads +public/image/barcode public/image \ No newline at end of file diff --git a/app/admin/lists/store_branch_product/StoreBranchProductLists.php b/app/admin/lists/store_branch_product/StoreBranchProductLists.php index a15a4e13..cce4193a 100644 --- a/app/admin/lists/store_branch_product/StoreBranchProductLists.php +++ b/app/admin/lists/store_branch_product/StoreBranchProductLists.php @@ -58,7 +58,7 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI } } return StoreBranchProduct::where($this->searchWhere)->where($where) - ->field(['id','store_id','product_id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost', 'status']) + ->field(['id','store_id','product_id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost','purchase', 'status']) ->when(!empty($this->adminInfo['store_id']), function ($query) { $query->where('store_id', $this->adminInfo['store_id']); }) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 10b19645..2a650373 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -66,30 +66,33 @@ class OrderLogic extends BaseLogic try { self::$total_price = 0; self::$pay_price = 0; - self::$cost = 0; //成本 + self::$cost = 0; //成本由采购价替代原成本为门店零售价 self::$profit = 0; //利润 self::$activity_price = 0; //活动减少 /** 计算价格 */ foreach ($cart_select as $k => $v) { - $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field('id branch_product_id,store_name,image,unit,price,vip_price,cost,product_id')->withTrashed()->find(); + $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field('id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id')->withTrashed()->find(); if (!$find) { continue; } unset($cart_select[$k]['id']); + if($user && in_array($user['user_ship'],UserShipEnum::DISCOUNT_ARRAY)){ + $find['price'] = $find['cost']; + } $cart_select[$k]['price'] = $find['price']; $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 $cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额 if ($user && $user['user_ship'] == 4) { - $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2); + $deduction_price_count=bcmul(bcsub($find['price'], $find['purchase'], 2),$v['cart_num'],2); $cart_select[$k]['deduction_price'] =$deduction_price_count; self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); } //利润 // $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润 - $cart_select[$k]['cost'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0; //成本 + $cart_select[$k]['purchase'] = bcmul($v['cart_num'], $find['purchase'], 2) ?? 0; //成本 $cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单支付金额 $cart_select[$k]['product_id'] = $find['product_id']; $cart_select[$k]['old_cart_id'] = $v['id']; @@ -110,7 +113,7 @@ class OrderLogic extends BaseLogic $cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name'); self::$total_price = bcadd(self::$total_price, $cart_select[$k]['total_price'], 2); self::$pay_price = bcadd(self::$pay_price, $cart_select[$k]['pay_price'], 2); - self::$cost = bcadd(self::$cost, $cart_select[$k]['cost'], 2); + self::$cost = bcadd(self::$cost, $cart_select[$k]['purchase'], 2); // self::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2); } $pay_price =bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额 @@ -141,7 +144,7 @@ class OrderLogic extends BaseLogic if ($params['store_id']) { $order['default_delivery'] = SystemStore::where('id', $params['store_id'])->value('is_send'); } - if($user['user_ship']>=1 &&$user['user_ship']<=3){ + if($user && $user['user_ship']>=1 &&$user['user_ship']<=3){ $order['is_vip'] = 1; } diff --git a/app/common/enum/UserShipEnum.php b/app/common/enum/UserShipEnum.php index ea4b84cc..772a5445 100644 --- a/app/common/enum/UserShipEnum.php +++ b/app/common/enum/UserShipEnum.php @@ -8,9 +8,14 @@ class UserShipEnum * 会员等级 */ const VIP1 = 1; - const VIP2 = 7; - const VIP3 = 8; - const VIP4 = 9; - const VIP5 = 10; + const VIP2 = 2; + const VIP3 = 3; + const VIP4 = 4; + const VIP5 = 5; + + /** + * 切换折扣价 + */ + const DISCOUNT_ARRAY = [4,5,6]; } \ No newline at end of file diff --git a/app/queue/redis/StoreStorageSend.php b/app/queue/redis/StoreStorageSend.php index f2069763..3e755bd3 100644 --- a/app/queue/redis/StoreStorageSend.php +++ b/app/queue/redis/StoreStorageSend.php @@ -56,7 +56,8 @@ class StoreStorageSend implements Consumer 'cate_id' => $find['cate_id'], 'price' => $find['price'], // 'cost' => $find['cost'], //v1.0 - 'cost' => $find['purchase'], + 'cost' => $find['cost'], + 'purchase' => $find['purchase'], 'vip_price' => $find['vip_price'], 'unit' => $find['unit'], 'batch' => $find['batch'], @@ -117,6 +118,7 @@ class StoreStorageSend implements Consumer 'cate_id' => $find['cate_id'], 'price' => $find['price'], 'cost' => $find['cost'], + 'purchase' => $find['purchase'], 'vip_price' => $find['vip_price'], 'unit' => $find['unit'], 'store_id' => $store_id, diff --git a/app/store/controller/WorkbenchController.php b/app/store/controller/WorkbenchController.php index 3ca20e3c..6617466c 100644 --- a/app/store/controller/WorkbenchController.php +++ b/app/store/controller/WorkbenchController.php @@ -3,12 +3,14 @@ namespace app\store\controller; use app\common\controller\Definitions; +use app\common\model\dict\DictType; use app\store\lists\store_order\StoreOrderLists; use app\store\logic\WorkbenchLogic; // #[ApiDoc\Title('工作台')] class WorkbenchController extends BaseAdminController { + public $notNeedLogin = ['recharge_statistics']; // #[ // ApiDoc\Title('交易统计'), @@ -159,4 +161,13 @@ class WorkbenchController extends BaseAdminController $result = WorkbenchLogic::revenueStatistics($params); return $this->data($result); } + + + public function recharge_statistics() + { + $params['store_id'] = DictType::where('type','store')->value('remark')??5; + $result = WorkbenchLogic::rechargeData($params); + return $this->data($result); + + } } diff --git a/app/store/logic/WorkbenchLogic.php b/app/store/logic/WorkbenchLogic.php index 8f349359..53aa4eec 100644 --- a/app/store/logic/WorkbenchLogic.php +++ b/app/store/logic/WorkbenchLogic.php @@ -709,6 +709,14 @@ class WorkbenchLogic extends BaseLogic } + public static function rechargeData($params) + { + $data['receipt_amount'] = UserRecharge::where([ + 'store_id'=>$params['store_id'], + 'paid'=>YesNoEnum::YES + ])->sum('price'); + return $data??[]; + }