diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index 3bfcd58e7..c864e6e15 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -66,6 +66,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa } } $is_warehouse=$this->request->get('is_warehouse',0); + $order_type=$this->request->get('order_type',0); $userShip = 0; if (!empty($this->params['user_id'])) { $userShip = User::where('id', $this->params['user_id'])->value('user_ship'); @@ -87,7 +88,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa } $list = $query->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) - ->select()->each(function ($item) use($is_warehouse, $userShip) { + ->select()->each(function ($item) use($is_warehouse, $userShip,$order_type) { $item['product_id'] = $item['id']; $item['bar_code_two'] = ''; if (in_array($item['unit'], [2, 21])) { @@ -142,6 +143,15 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa }else{ $item['status_msg']='下架|不常用|是否有替换'; } + if ($order_type == 2) { + $price=StoreProductGroupPrice::where('group_id', 42)->where('product_id', $item['product_id'])->value('price'); + if($price>0){ + $item['price'] = $price; + $item['store_name'] = $item['store_name'].'|活动价'; + } + } + + return $item; })?->toArray(); // if ($userShip > 0 && $userShip != 4) { diff --git a/app/api/logic/DemoLogic.php b/app/api/logic/DemoLogic.php index 15574a51b..83e01edb2 100644 --- a/app/api/logic/DemoLogic.php +++ b/app/api/logic/DemoLogic.php @@ -3,6 +3,7 @@ namespace app\api\logic; use app\common\logic\BaseLogic; +use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_product\StoreProduct; use app\common\model\store_product_group_price\StoreProductGroupPrice; use think\facade\Db; @@ -14,8 +15,8 @@ class DemoLogic extends BaseLogic $arr = Db::name('ceshi_two')->select(); foreach ($arr as $k => $v) { //门店供货、商户、零售 - $res=Db::name('store_product')->where('id', $v['product_id'])->update(['purchase' => $v['price'], 'cost' => bcadd($v['price1'], 0, 2), 'vip_price' => bcadd($v['price1'], 0, 2), 'price' => bcadd($v['price6'], 0, 2)]); - if($res){ + $res = Db::name('store_product')->where('id', $v['product_id'])->update(['purchase' => $v['price'], 'cost' => bcadd($v['price1'], 0, 2), 'vip_price' => bcadd($v['price1'], 0, 2), 'price' => bcadd($v['price6'], 0, 2)]); + if ($res) { Db::name('ceshi_two')->where('product_id', $v['product_id'])->update(['status' => 1]); } //种养殖 @@ -67,6 +68,23 @@ class DemoLogic extends BaseLogic } else { StoreProductGroupPrice::insert(['product_id' => $v['product_id'], 'group_id' => 20, 'price' => bcadd($v['price4'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv4'], 100), 100, 2)]); } + //活动价 + $find42 = StoreProductGroupPrice::where('product_id', $v['product_id'])->where('group_id', 42)->find(); + if ($find42) { + $find42->save(['price' => bcadd($v['price4'], 0, 2)]); + } else { + StoreProductGroupPrice::insert(['product_id' => $v['product_id'], 'group_id' => 42, 'price' => bcadd($v['price9'], 0, 2), 'price_type' => 3, 'base_rate' =>0]); + } + } + } + + public static function test2($store_id, $srr) + { + foreach ($srr as $k => $v) { + $find = StoreBranchProduct::where('store_id', $store_id)->where('product_id', $v['product_id'])->find(); + $find->stock = bcsub($find->stock, $v['cart_num'], 2); + $find->save(); + SqlChannelLog('StoreBranchProduct', $find['id'], $v['cart_num'], -1, Request()->url(), 1); } } }