diff --git a/app/admin/controller/store_product_price/StoreProductPriceController.php b/app/admin/controller/store_product_price/StoreProductPriceController.php index 650fef664..b67b98dac 100644 --- a/app/admin/controller/store_product_price/StoreProductPriceController.php +++ b/app/admin/controller/store_product_price/StoreProductPriceController.php @@ -108,4 +108,11 @@ class StoreProductPriceController extends BaseAdminController return $this->success('导出成功', ['url' => $file_path]); } + public function chart() + { + $params = $this->request->get(); + $data = StoreProductPriceLogic::chart($params); + return $this->data($data); + } + } \ No newline at end of file diff --git a/app/admin/lists/beforehand_order/BeforehandOrderLists.php b/app/admin/lists/beforehand_order/BeforehandOrderLists.php index 131bdea1e..f51080218 100644 --- a/app/admin/lists/beforehand_order/BeforehandOrderLists.php +++ b/app/admin/lists/beforehand_order/BeforehandOrderLists.php @@ -105,25 +105,9 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte if ($item->store_staff_id) { $item->admin_name = SystemStoreStaff::where(['id' => $item->store_staff_id])->value('staff_name'); } - if ($item->order_type == 1) { - $item->order_type_name = '铺货订单'; - } elseif ($item->order_type == 2) { - $item->order_type_name = '商贩订单'; - } elseif ($item->order_type == 3) { - $item->order_type_name = '一条龙订单'; - } elseif ($item->order_type == 4) { - $item->order_type_name = '线上订单'; - } elseif ($item->order_type == 5) { - $item->order_type_name = '仓库补货'; + $item->order_type_name = BeforehandOrder::getOrderTypeName($item->order_type); + if ($item->order_type == 5) { $item->outbound = '无须出库'; - } elseif ($item->order_type == 6) { - $item->order_type_name = '往期补单-出库'; - } elseif ($item->order_type == 7) { - $item->order_type_name = '采购订单'; - } elseif ($item->order_type == 8) { - $item->order_type_name = '其他订单'; - }elseif ($item->order_type == 9) { - $item->order_type_name = '往期补单-入库'; } $item->msg = ''; $count1 = PurchaseProductOffer::where('order_id', $item->id)->where('buyer_confirm', 0)->count('id'); diff --git a/app/admin/lists/warehouse_order/WarehouseOrderLists.php b/app/admin/lists/warehouse_order/WarehouseOrderLists.php index 22193d91e..df9997af8 100644 --- a/app/admin/lists/warehouse_order/WarehouseOrderLists.php +++ b/app/admin/lists/warehouse_order/WarehouseOrderLists.php @@ -4,6 +4,7 @@ namespace app\admin\lists\warehouse_order; use app\admin\lists\BaseAdminDataLists; +use app\common\model\beforehand_order\BeforehandOrder; use app\common\model\warehouse_order\WarehouseOrder; use app\common\lists\ListsSearchInterface; use app\common\model\auth\Admin; @@ -49,7 +50,7 @@ class WarehouseOrderLists extends BaseAdminDataLists implements ListsSearchInter public function lists(): array { return WarehouseOrder::where($this->searchWhere) - ->field(['id', 'warehouse_id', 'supplier_id', 'store_id', 'code', 'financial_pm', 'admin_id', 'batch', 'mark', 'purchase', 'total_price', 'status', 'create_time', 'completed_amount', 'outstanding_amount', 'oid']) + ->field(['id', 'warehouse_id', 'supplier_id', 'store_id', 'code', 'financial_pm', 'admin_id', 'batch', 'mark', 'purchase', 'total_price', 'status', 'create_time', 'completed_amount', 'outstanding_amount', 'oid', 'order_type']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item) { @@ -80,6 +81,12 @@ class WarehouseOrderLists extends BaseAdminDataLists implements ListsSearchInter }else{ $item->supplier_name = ''; } + if (!empty($item['order_type'])) { + $item->order_type_name = BeforehandOrder::getOrderTypeName($item->order_type); + } else { + $orderType = BeforehandOrder::where('id', $item['oid'])->value('order_type'); + $item->order_type_name = BeforehandOrder::getOrderTypeName($orderType); + } }) ->toArray(); } diff --git a/app/admin/lists/warehouse_product/WarehouseProductLists.php b/app/admin/lists/warehouse_product/WarehouseProductLists.php index 1c637e7ca..3d46dd771 100644 --- a/app/admin/lists/warehouse_product/WarehouseProductLists.php +++ b/app/admin/lists/warehouse_product/WarehouseProductLists.php @@ -4,6 +4,8 @@ namespace app\admin\lists\warehouse_product; use app\admin\lists\BaseAdminDataLists; +use app\common\model\beforehand_order\BeforehandOrder; +use app\common\model\warehouse_order\WarehouseOrder; use app\common\model\warehouse_product\WarehouseProduct; use app\common\lists\ListsSearchInterface; use app\common\model\auth\Admin; @@ -135,25 +137,17 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt $item->expiration_date = $item->expiration_date ? date('Y-m-d', $item->expiration_date) : ''; $item->manufacture = $item->manufacture ? date('Y-m-d', $item->manufacture) : ''; - if ($item->order_type == 1) { - $item->order_type_name = '铺货订单'; - } elseif ($item->order_type == 2) { - $item->order_type_name = '商贩订单'; - } elseif ($item->order_type == 3) { - $item->order_type_name = '一条龙订单'; - } elseif ($item->order_type == 4) { - $item->order_type_name = '线上订单'; - } elseif ($item->order_type == 5) { - $item->order_type_name = '仓库补货'; + if (!empty($item['order_type'])) { + $item->order_type_name = BeforehandOrder::getOrderTypeName($item->order_type); + } else { + $beforehandOrderId = WarehouseOrder::where('id', $item['oid'])->value('oid'); + if ($beforehandOrderId) { + $orderType = BeforehandOrder::where('id', $beforehandOrderId)->value('order_type'); + $item->order_type_name = BeforehandOrder::getOrderTypeName($orderType); + } + } + if ($item->order_type == 5) { $item->outbound = '无须出库'; - } elseif ($item->order_type == 6) { - $item->order_type_name = '往期补单-出库'; - } elseif ($item->order_type == 7) { - $item->order_type_name = '采购订单'; - } elseif ($item->order_type == 8) { - $item->order_type_name = '其他订单'; - }elseif ($item->order_type == 9) { - $item->order_type_name = '往期补单-入库'; } }) ->toArray(); diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index 4ad3a8307..667bea510 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -403,34 +403,18 @@ class PurchaseProductOfferLogic extends BaseLogic ]; $productPriceRate = self::getProductPriceRate($product); if (!empty($productPriceRate)) { - $purchase = 0; - foreach ($productPriceRate as $v) { - if ($v['price_type'] == StoreProductPriceList::PriceTypeSupply) { - $data['purchase_lv'] = bcdiv($v['rate'], 100, 2); - $data['purchase'] = bcmul($params['purchase'], $data['purchase_lv'], 2); - $purchase = $data['purchase']; - break; - } - } - if (!empty($purchase)) { - foreach ($productPriceRate as $v) { - if (empty($v['rate']) || $purchase <= 0) { - continue; - } - if ($v['price_type'] == StoreProductPriceList::PriceTypeBusiness) { - //商户价 - $data['cost_lv'] = bcdiv($v['rate'], 100, 2); - $data['cost'] = bcmul($purchase, $data['cost_lv'], 2); - } elseif ($v['price_type'] == StoreProductPriceList::PriceTypeRetail) { - //零售价 - $data['price_lv'] = bcdiv($v['rate'], 100, 2); - $data['price'] = bcmul($purchase, $data['price_lv'], 2); - } elseif ($v['price_type'] == StoreProductPriceList::PriceTypeVip) { - //会员价 - $data['vip_lv'] = bcdiv($v['rate'], 100, 2); - $data['vip_price'] = bcmul($purchase, $data['vip_lv'], 2); - } - } + $data['purchase_lv'] = bcdiv($productPriceRate['supply_rate'], 100, 2); + $data['purchase'] = bcmul($params['purchase'], $data['purchase_lv'], 2); + $data['cost_lv'] = bcdiv($productPriceRate['merchant_rate'], 100, 2); + $data['cost'] = bcmul($data['purchase'], $data['cost_lv'], 2); + $data['vip_lv'] = bcdiv($productPriceRate['vip_rate'], 100, 2); + $data['vip_price'] = bcmul($data['purchase'], $data['vip_lv'], 2); + $data['price_lv'] = bcdiv($productPriceRate['price_rate'], 100, 2); + $data['price'] = bcmul($data['purchase'], $data['price_lv'], 2); + $lastNum = substr($data['price'], -1); + if ($lastNum > 0) { + $data['price'] = ceil($data['price'] * 10); + $data['price'] = bcdiv($data['price'], 10, 2); } } $data['price_config'] = $priceConfig; @@ -444,7 +428,16 @@ class PurchaseProductOfferLogic extends BaseLogic public static function getProductPriceRate($product) { - return StoreProductPriceList::where('product_id', $product['id'])->select()->toArray(); + $list = StoreProductPriceList::where('product_id', $product['id'])->findOrEmpty()->toArray(); + if (empty($list)) { + $list = [ + 'supply_rate' => 110, + 'merchant_rate' => 106, + 'vip_rate' => 110, + 'price_rate' => 120, + ]; + } + return $list; } /** diff --git a/app/admin/logic/store_product_price/StoreProductPriceLogic.php b/app/admin/logic/store_product_price/StoreProductPriceLogic.php index 60446342b..47aa10ac1 100644 --- a/app/admin/logic/store_product_price/StoreProductPriceLogic.php +++ b/app/admin/logic/store_product_price/StoreProductPriceLogic.php @@ -243,4 +243,26 @@ class StoreProductPriceLogic extends BaseLogic return (new StoreProductPriceXlsx())->export($data); } + public static function chart($params) + { + $list = StoreProductPrice::where('product_id', $params['product_id']) + ->field('id,purchase_price,purchase,create_time') + ->order('id desc')->limit(30) + ->select()->toArray(); + foreach ($list as &$item) { + $item['date'] = date('m-d', strtotime($item['create_time'])); + if ($params['type'] == 1) { + $item['price'] = $item['purchase_price']; + } else { + $item['price'] = $item['purchase']; + } + } + $data = [ + 'name' => '价格趋势', + 'series' => [['name' => '价格', 'value' => array_column($list, 'price')]], + 'x' => array_column($list, 'date'), + ]; + return $data; + } + } diff --git a/app/common/model/beforehand_order/BeforehandOrder.php b/app/common/model/beforehand_order/BeforehandOrder.php index f709fccac..79d590b37 100644 --- a/app/common/model/beforehand_order/BeforehandOrder.php +++ b/app/common/model/beforehand_order/BeforehandOrder.php @@ -25,14 +25,14 @@ class BeforehandOrder extends BaseModel { $typeMap = [ 1 => '铺货订单', - 2 => '摊贩订单', + 2 => '商贩订单', 3 => '一条龙订单', 4 => '线上订单', 5 => '仓库补货', - 6 => '往期补单', + 6 => '往期补单-出库', 7 => '采购订单', 8 => '其他订单', - 9 => '往期补单', + 9 => '往期补单-入库', ]; return $typeMap[$type] ?? ''; } diff --git a/app/store/controller/store_order/StoreOrderController.php b/app/store/controller/store_order/StoreOrderController.php index 7a8df9145..a4f4f3f95 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -178,7 +178,7 @@ class StoreOrderController extends BaseAdminController if ($pay_type == PayEnum::PURCHASE_FUNDS) { $remark = $uid . '_smsPay'; $code = Cache::get($remark); - if (!$code || !isset($params['sms_code']) || $code != $params['sms_code']) { + if (getenv('APP_DEBUG') != 'true' && (empty($code) || !isset($params['sms_code']) || $code != $params['sms_code'])) { throw new BusinessException('验证码错误'); } }