From 86235aed0844fd53d5da21c18b7096d7a85a3378 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Sun, 18 Aug 2024 17:02:40 +0800 Subject: [PATCH 1/9] =?UTF-8?q?feat(inventory=5Ftransfer):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD=E6=9A=82=E6=9C=AA?= =?UTF-8?q?=E5=BC=80=E6=94=BE=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InventoryTransferController.php | 1 + .../InventoryTransferLists.php | 17 ++++-- .../InventoryTransferLogic.php | 58 ++++++++++++------- .../PurchaseProductOfferLogic.php | 17 +++--- .../InventoryTransferValidate.php | 2 +- 5 files changed, 60 insertions(+), 35 deletions(-) diff --git a/app/admin/controller/inventory_transfer/InventoryTransferController.php b/app/admin/controller/inventory_transfer/InventoryTransferController.php index c334c284b..ee7175207 100644 --- a/app/admin/controller/inventory_transfer/InventoryTransferController.php +++ b/app/admin/controller/inventory_transfer/InventoryTransferController.php @@ -72,6 +72,7 @@ class InventoryTransferController extends BaseAdminController */ public function delete() { + return $this->fail('删除功能暂未开放'); $params = (new InventoryTransferValidate())->post()->goCheck('delete'); InventoryTransferLogic::delete($params); return $this->success('删除成功', [], 1, 1); diff --git a/app/admin/lists/inventory_transfer/InventoryTransferLists.php b/app/admin/lists/inventory_transfer/InventoryTransferLists.php index 5b6f4992a..201538979 100644 --- a/app/admin/lists/inventory_transfer/InventoryTransferLists.php +++ b/app/admin/lists/inventory_transfer/InventoryTransferLists.php @@ -70,20 +70,27 @@ class InventoryTransferLists extends BaseAdminDataLists implements ListsSearchIn } return InventoryTransfer::where($this->searchWhere) - ->field(['id', 'product_id', 'nums', 'one_before_nums', 'one_after_nums','two_before_nums','two_after_nums', 'type', 'one_id', 'two_id', 'create_time']) + ->field(['id', 'product_id', 'nums', 'one_before_nums', 'one_after_nums','two_before_nums','two_after_nums', 'one_type','two_type', 'one_id', 'two_id', 'create_time']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item){ $item->store_name= StoreProduct::where('id',$item->product_id)->value('store_name'); - if($item->type==1){ - $item->type_name='商户'; + $type_name=''; + if($item->one_type==1){ $item->one_name=SystemStore::where('id',$item->one_id)->value('name'); + $type_name='门店转'; + }else{ + $item->one_name=Warehouse::where('id',$item->one_id)->value('name'); + $type_name='仓库转'; + } + if($item->two_type==1){ + $type_name.='门店'; $item->two_name=SystemStore::where('id',$item->two_id)->value('name'); }else{ - $item->type_name='仓库'; - $item->one_name=Warehouse::where('id',$item->one_id)->value('name'); + $type_name.='仓库'; $item->two_name=Warehouse::where('id',$item->two_id)->value('name'); } + $item->type_name=$type_name; $item->store_name= StoreProduct::where('id',$item->product_id)->value('store_name'); }) ->toArray(); diff --git a/app/admin/logic/inventory_transfer/InventoryTransferLogic.php b/app/admin/logic/inventory_transfer/InventoryTransferLogic.php index aba3a91b9..445a69b3d 100644 --- a/app/admin/logic/inventory_transfer/InventoryTransferLogic.php +++ b/app/admin/logic/inventory_transfer/InventoryTransferLogic.php @@ -2,7 +2,7 @@ namespace app\admin\logic\inventory_transfer; - +use app\admin\logic\warehouse_product\WarehouseProductLogic; use app\common\model\inventory_transfer\InventoryTransfer; use app\common\logic\BaseLogic; use app\common\model\store_branch_product\StoreBranchProduct; @@ -32,33 +32,43 @@ class InventoryTransferLogic extends BaseLogic $one_after_nums = 0; $two_before_nums = 0; $two_after_nums = 0; - if ($params['type'] == 1) { + if($params['one_type']==1){ $stock = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['one_id'])->value('stock'); - $stock_two = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->value('stock'); if ($stock < $params['nums']) { self::setError('调拨数量不能大于当前门店库存'); return false; - } else { - $one_before_nums = $stock; - $one_after_nums = bcsub($stock, $params['nums']); - - $two_before_nums = $stock_two; - $two_after_nums = bcadd($stock_two, $params['nums']); } - } elseif ($params['type'] == 2) { + if($params['two_type']==1){ + $stock_two = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->value('stock'); + }elseif($params['two_type']==2){ + $stock_two = WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['two_id'])->value('nums'); + } + $one_before_nums = $stock; + $one_after_nums = bcsub($stock, $params['nums']); + + $two_before_nums = $stock_two; + $two_after_nums = bcadd($stock_two, $params['nums']); + }elseif($params['one_type']==2){ $stock = WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['one_id'])->value('nums'); - $stock_two = WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['two_id'])->value('nums'); if ($stock < $params['nums']) { self::setError('调拨数量不能大于当前仓库库存'); return false; - } else { - $one_before_nums = $stock; - $one_after_nums = bcsub($stock, $params['nums']); - - $two_before_nums = $stock_two; - $two_after_nums = bcadd($stock_two, $params['nums']); } + if($params['two_type']==1){ + $stock_two = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->value('stock'); + }elseif($params['two_type']==2){ + $stock_two = WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['two_id'])->value('nums'); + } + $one_before_nums = $stock; + $one_after_nums = bcsub($stock, $params['nums']); + + $two_before_nums = $stock_two; + $two_after_nums = bcadd($stock_two, $params['nums']); + }else{ + self::setError('调拨类型错误'); + return false; } + Db::startTrans(); try { InventoryTransfer::create([ @@ -68,20 +78,24 @@ class InventoryTransferLogic extends BaseLogic 'one_after_nums' => $one_after_nums, 'two_before_nums' => $two_before_nums, 'two_after_nums' => $two_after_nums, - 'type' => $params['type'], + 'one_type' => $params['one_type'], + 'two_type' => $params['two_type'], 'one_id' => $params['one_id'], 'two_id' => $params['two_id'] ]); - if ($params['type'] == 1) { + if($params['one_type']==1){ StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['one_id'])->dec('stock', $params['nums'])->update(); - StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->inc('stock', $params['nums'])->update(); - } elseif ($params['type'] == 2) { + } elseif ($params['one_type'] == 2) { WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['one_id'])->dec('nums', $params['nums'])->update(); + } + if($params['two_type']==1){ + StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->inc('stock', $params['nums'])->update(); + } elseif ($params['two_type'] == 2) { WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['two_id'])->inc('nums', $params['nums'])->update(); } Db::commit(); return true; - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollback(); self::setError($e->getMessage()); return false; diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index 79e1c412f..d9b5fc996 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -5,6 +5,7 @@ namespace app\admin\logic\purchase_product_offer; use app\common\model\purchase_product_offer\PurchaseProductOffer; use app\common\logic\BaseLogic; +use app\common\model\delivery_service\DeliveryService; use think\facade\Db; @@ -103,15 +104,17 @@ class PurchaseProductOfferLogic extends BaseLogic */ public static function buyer($params) { + if($params['is_buyer']==1){ + if($params['buyer_id']==''){ + self::setError('采购人不能为空'); + return false; + } + $data['buyer_id']=$params['buyer_id']; + $data['buyer_nums']=$params['buyer_nums']; + } Db::startTrans(); try { - $data=[ - 'is_buyer' => $params['is_buyer'], - ]; - if($params['is_buyer']==1){ - $data['buyer_id']=$params['buyer_id']; - $data['buyer_nums']=$params['buyer_nums']; - } + $data['is_buyer']=$params['is_buyer']; PurchaseProductOffer::where('id', $params['id'])->update($data); Db::commit(); return true; diff --git a/app/admin/validate/inventory_transfer/InventoryTransferValidate.php b/app/admin/validate/inventory_transfer/InventoryTransferValidate.php index 7149f7f18..dd55ec814 100644 --- a/app/admin/validate/inventory_transfer/InventoryTransferValidate.php +++ b/app/admin/validate/inventory_transfer/InventoryTransferValidate.php @@ -50,7 +50,7 @@ class InventoryTransferValidate extends BaseValidate */ public function sceneAdd() { - return $this->only(['product_id','nums','type','one_id','two_id']); + return $this->only(['product_id','nums','one_id','two_id']); } From 98abb7867091c1db8740169853830fc02713d7f2 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 19 Aug 2024 11:10:41 +0800 Subject: [PATCH 2/9] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BA=86?= =?UTF-8?q?=E5=BA=97=E9=93=BA=E8=8E=B7=E5=8F=96=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E7=BB=8F=E7=BA=AC=E5=BA=A6=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=9C=80=E8=BF=91=E7=9A=84=E5=BA=97=E9=93=BA=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86=E7=9B=B8=E5=85=B3API=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/IndexController.php | 19 +++++++++++++-- app/api/lists/order/CartList.php | 2 +- app/api/logic/order/OrderLogic.php | 32 +++++++------------------ app/common/service/xlsx/OrderDetail.php | 2 +- 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index 9f6b13c40..57afc2be3 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -207,8 +207,23 @@ class IndexController extends BaseApiController */ public function config() { - $store_id = getenv('STORE_ID') ?? 1; - $find = SystemStore::where('id', $store_id)->find(); + //处理返回最近的店铺 + $params=$this->request->get(); + if ((isset($params['lat']) && $params['lat'] != '') && (isset($params['long']) && $params['long'] != '')) { + $latitude = $params['lat']; + $longitude = $params['long']; + // 计算距离的SQL表达式 + $distanceSql = "SQRT(POW(69.1 * (latitude - {$latitude}), 2) + + POW(69.1 * ({$longitude} - longitude) * COS(latitude / 57.3), 2))"; + $find = SystemStore::field("id, name, {$distanceSql} AS distance") + ->where('latitude', '<>', '') + ->where('longitude', '<>', '') + ->order('distance', 'asc') // 根据距离排序 + ->find(); + } else { + $store_id = getenv('STORE_ID') ?? 1; + $find = SystemStore::where('id', $store_id)->find(); + } $list = [ 'id' => $find['id'], 'store_name' => $find['name'], diff --git a/app/api/lists/order/CartList.php b/app/api/lists/order/CartList.php index f4bd5270f..36bad71ea 100644 --- a/app/api/lists/order/CartList.php +++ b/app/api/lists/order/CartList.php @@ -35,7 +35,7 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists */ public function setSearch(): array { - return []; + return ['='=>['store_id']]; } diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index e80e14777..17b1f9c44 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -227,30 +227,14 @@ class OrderLogic extends BaseLogic if (isset($params['source']) && $params['source'] > 0) { $order['source'] = $params['source']; } - //处理返回最近的店铺 - if ((isset($params['lat']) && $params['lat'] != '') && (isset($params['long']) && $params['long'] != '')) { - $storeAll = SystemStore::field('id,name,phone,address,detailed_address,latitude,longitude')->select()->toArray(); - $nearestStore = null; - $minDistance = PHP_FLOAT_MAX; - foreach ($storeAll as $value) { - $value['distance'] = haversineDistance($value['latitude'], $value['longitude'], $params['lat'], $params['long']); - if ($value['distance'] < $minDistance) { - $minDistance = $value['distance']; - $nearestStore = $value; - } - } - $store['near_store'] = []; - if ($nearestStore) { - $store['near_store'] = $nearestStore; - } + + if (isset($params['store_id']) && $params['store_id'] > 0) { + $store_id = $params['store_id']; } else { - if (isset($params['store_id']) && $params['store_id'] > 0) { - $store_id = $params['store_id']; - } else { - $store_id = getenv('STORE_ID') ?? 1; - } - $store['near_store'] = SystemStore::where('id', $store_id)->field('id,name,phone,address,detailed_address,latitude,longitude')->find() ?? []; + $store_id = getenv('STORE_ID') ?? 1; } + $store['near_store'] = SystemStore::where('id', $store_id)->field('id,name,phone,address,detailed_address,latitude,longitude')->find() ?? []; + if ($user) { $order['address_id'] = UserAddress::where('uid', $user['id'])->where('is_default', 1)->value('id') ?? 0; } @@ -264,13 +248,13 @@ class OrderLogic extends BaseLogic // 使用DateTime::format()方法获取时间并比较 if ($currentTime->format('H:i') > $fourPM->format('H:i')) { $currentDate = date('Y-m-d'); - $alert='当前时间超过配送截止时间16:00,若下单,物品送达时间为'.date('Y-m-d', strtotime($currentDate. '+2 days')); + $alert = '当前时间超过配送截止时间16:00,若下单,物品送达时间为' . date('Y-m-d', strtotime($currentDate . '+2 days')); } } catch (\Exception $e) { self::setError($e->getMessage()); return false; } - return ['order' => $order, 'cart_list' => $cart_select, 'shopInfo' => $store['near_store'],'alert'=>$alert]; + return ['order' => $order, 'cart_list' => $cart_select, 'shopInfo' => $store['near_store'], 'alert' => $alert]; } /** diff --git a/app/common/service/xlsx/OrderDetail.php b/app/common/service/xlsx/OrderDetail.php index 6e4ac057b..786aea9aa 100644 --- a/app/common/service/xlsx/OrderDetail.php +++ b/app/common/service/xlsx/OrderDetail.php @@ -11,7 +11,7 @@ class OrderDetail { public $warehouse='海吉星仓库'; - public $company='共投里海'; + public $company='供投里海'; public $address='泸州龙马潭区海吉星122栋'; public $phone='08302669767'; public $tel='17309099881'; From 9e0e1524f2442bf903d7d05be7f5f1425ebac42f Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 19 Aug 2024 11:16:04 +0800 Subject: [PATCH 3/9] =?UTF-8?q?feat(order):=20=E6=B7=BB=E5=8A=A0=E9=97=A8?= =?UTF-8?q?=E5=BA=97=E9=80=89=E6=8B=A9=E5=88=A4=E6=96=AD=E5=92=8C=E5=95=86?= =?UTF-8?q?=E5=93=81=E6=9F=A5=E8=AF=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 17b1f9c44..ea1816a0a 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -66,6 +66,11 @@ class OrderLogic extends BaseLogic */ static public function cartIdByOrderInfo($cartId, $addressId, $user = null, $params = [], $createOrder = 0) { + if(empty($params['store_id']) || $params['store_id'] <= 0){ + self::setError('请选择门店'); + return false; + } + $where = ['is_pay' => 0]; $cart_select = Cart::whereIn('id', $cartId)->where($where)->field('id,product_id,cart_num')->select()->toArray(); if (empty($cart_select)) { @@ -84,9 +89,9 @@ class OrderLogic extends BaseLogic self::$fresh_price = 0; //生鲜金额 /** 计算价格 */ $off_activity = Config::where('name', 'off_activity')->value('value'); - $field = 'id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose'; + $field = 'product_id id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose'; foreach ($cart_select as $k => $v) { - $find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find(); + $find = StoreBranchProduct::where(['product_id' => $v['product_id'],'store_id'=>$params['store_id']])->field($field)->find(); if (!$find) { self::setError('商品不存在'); return false; @@ -114,7 +119,8 @@ class OrderLogic extends BaseLogic $price = $find['cost']; } else { $price = $find['price']; - if (isset($params['store_id']) && $params['store_id'] == getenv('ACTIVITY_STORE_ID')) { + //单门店活动判断 + if ($params['store_id'] == getenv('ACTIVITY_STORE_ID')) { $storeBranchPrice = StoreBranchProduct::where('store_id', getenv('ACTIVITY_STORE_ID'))->where('product_id', $v['product_id'])->value('price'); if ($storeBranchPrice) { $price = $storeBranchPrice; From 610514e8d69137443c7f15db8e315349a113e17f Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 19 Aug 2024 17:58:45 +0800 Subject: [PATCH 4/9] =?UTF-8?q?feat(PurchaseOrderInfoLists):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0StoreBranchProduct=E6=A8=A1=E5=9E=8B=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=8F=8A=E5=BA=93=E5=AD=98=E6=9F=A5=E8=AF=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PurchaseOrderInfoController.php | 39 ++++++++++++++++ .../PurchaseOrderInfoLists.php | 12 ++++- .../purchase_order/PurchaseOrderLogic.php | 24 +++++----- .../PurchaseOrderInfoLogic.php | 44 +++++++++++++++++++ 4 files changed, 106 insertions(+), 13 deletions(-) create mode 100644 app/admin/controller/purchase_order_info/PurchaseOrderInfoController.php create mode 100644 app/admin/logic/purchase_order_info/PurchaseOrderInfoLogic.php diff --git a/app/admin/controller/purchase_order_info/PurchaseOrderInfoController.php b/app/admin/controller/purchase_order_info/PurchaseOrderInfoController.php new file mode 100644 index 000000000..b60626e32 --- /dev/null +++ b/app/admin/controller/purchase_order_info/PurchaseOrderInfoController.php @@ -0,0 +1,39 @@ +request->post(); + switch ($params['type']) { + case 'buyer': + PurchaseOrderInfoLogic::buyer($params); + break; + default: + return $this->fail('参数错误'); + break; + } + if (PurchaseOrderInfoLogic::hasError()) { + return $this->fail(PurchaseOrderInfoLogic::getError()); + } + return $this->success('设置成功', [], 1, 1); + } +} \ No newline at end of file diff --git a/app/admin/lists/purchase_order_info/PurchaseOrderInfoLists.php b/app/admin/lists/purchase_order_info/PurchaseOrderInfoLists.php index b4dacaefe..335b45636 100644 --- a/app/admin/lists/purchase_order_info/PurchaseOrderInfoLists.php +++ b/app/admin/lists/purchase_order_info/PurchaseOrderInfoLists.php @@ -6,6 +6,7 @@ namespace app\admin\lists\purchase_order_info; use app\admin\lists\BaseAdminDataLists; use app\common\lists\ListsSearchInterface; use app\common\model\purchase_order_info\PurchaseOrderInfo; +use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_product\StoreProduct; use app\common\model\store_product_unit\StoreProductUnit; use app\common\model\system_store\SystemStore; @@ -48,13 +49,22 @@ class PurchaseOrderInfoLists extends BaseAdminDataLists implements ListsSearchIn ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item) { - $find=StoreProduct::where('id',$item->product_id)->field('store_info,unit,store_name,image')->find(); + $find=StoreBranchProduct::where('product_id',$item->product_id)->where('store_id',$item->store_id)->field('store_info,stock,unit,store_name,image')->find(); if($find){ $item->store_name=$find->store_name; $item->unit_name=StoreProductUnit::where('id',$find->unit)->value('name'); + $item->unit=$find->unit; + $item->stock=$find->stock; $item->store_info=$find->store_info; $item->image=$find->image; } + if($item->is_buyer==1){ + $item->is_buyer_name='需采购'; + }elseif($item->is_buyer==-1){ + $item->is_buyer_name='不采购'; + }else{ + $item->is_buyer_name='未知'; + } switch ($item->storage) { case 0: $item->storage_name = '未入库'; diff --git a/app/admin/logic/purchase_order/PurchaseOrderLogic.php b/app/admin/logic/purchase_order/PurchaseOrderLogic.php index 5e76b1133..7f7ddfdbb 100644 --- a/app/admin/logic/purchase_order/PurchaseOrderLogic.php +++ b/app/admin/logic/purchase_order/PurchaseOrderLogic.php @@ -112,18 +112,18 @@ class PurchaseOrderLogic extends BaseLogic $purchase_order_info_two[] = $arr; } $purchaseOrderInfo->saveAll($purchase_order_info_two); - $productOffer = []; - foreach ($info as $item) { - $arr['order_id'] = $res['id']; - $arr['product_id'] = $item['product_id']; - $arr['price'] = $item['price']; - $arr['total_price'] = $item['total_price']; - $arr['need_num'] = $item['cart_num']; - $arr['unit'] = StoreProduct::where('id', $item['product_id'])->value('unit'); - $productOffer[] = $arr; - } - $purchaseProductOffer = new PurchaseProductOffer(); - $purchaseProductOffer->saveAll($productOffer); + // $productOffer = []; + // foreach ($info as $item) { + // $arr['order_id'] = $res['id']; + // $arr['product_id'] = $item['product_id']; + // $arr['price'] = $item['price']; + // $arr['total_price'] = $item['total_price']; + // $arr['need_num'] = $item['cart_num']; + // $arr['unit'] = StoreProduct::where('id', $item['product_id'])->value('unit'); + // $productOffer[] = $arr; + // } + // $purchaseProductOffer = new PurchaseProductOffer(); + // $purchaseProductOffer->saveAll($productOffer); // StoreOrder::whereIn('id', $oid_arr)->update(['is_merge' => 1]); // Db::commit(); // return true; diff --git a/app/admin/logic/purchase_order_info/PurchaseOrderInfoLogic.php b/app/admin/logic/purchase_order_info/PurchaseOrderInfoLogic.php new file mode 100644 index 000000000..44d5483a4 --- /dev/null +++ b/app/admin/logic/purchase_order_info/PurchaseOrderInfoLogic.php @@ -0,0 +1,44 @@ +0) { + $data['buyer_nums'] = $params['buyer_nums']; + $find = PurchaseProductOffer::where('order_id', $params['poid'])->where('product_id', $params['product_id'])->find(); + if ($find) { + PurchaseProductOffer::where('id', $find['id'])->inc('buyer_nums', $params['buyer_nums'])->update(); + } else { + $arr['order_id'] = $params['poid']; + $arr['product_id'] = $params['product_id']; + $arr['need_num'] = $params['cart_num']; + $arr['buyer_nums'] = $params['buyer_nums']; + $arr['unit'] = StoreProduct::where('id', $params['product_id'])->value('unit'); + PurchaseProductOffer::create($arr); + } + } + PurchaseOrderInfo::where('id', $params['id'])->update($data); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } +} From 7a9c49f314bd70005ead683852a85c3c7252cf61 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 19 Aug 2024 20:06:25 +0800 Subject: [PATCH 5/9] =?UTF-8?q?feat(IndexController):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BA=86IndexController=E6=8E=A7=E5=88=B6=E5=99=A8=E4=B8=AD?= =?UTF-8?q?=E7=9A=84index=E6=96=B9=E6=B3=95=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BA=86=E5=BA=97=E9=93=BA=E8=8E=B7=E5=8F=96=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E6=A0=B9=E6=8D=AE=E7=BB=8F=E7=BA=AC=E5=BA=A6=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=9C=80=E8=BF=91=E7=9A=84=E5=BA=97=E9=93=BA=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E6=9B=B4=E6=96=B0=E4=BA=86=E7=9B=B8=E5=85=B3API?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/IndexController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index 57afc2be3..8804fcd31 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -215,7 +215,7 @@ class IndexController extends BaseApiController // 计算距离的SQL表达式 $distanceSql = "SQRT(POW(69.1 * (latitude - {$latitude}), 2) + POW(69.1 * ({$longitude} - longitude) * COS(latitude / 57.3), 2))"; - $find = SystemStore::field("id, name, {$distanceSql} AS distance") + $find = SystemStore::field("id, name,abbreviation, {$distanceSql} AS distance") ->where('latitude', '<>', '') ->where('longitude', '<>', '') ->order('distance', 'asc') // 根据距离排序 From 28e1c3fac166cce1045b46d96b4254ed236573e0 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 19 Aug 2024 20:09:03 +0800 Subject: [PATCH 6/9] =?UTF-8?q?feat(IndexController):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BA=86=E7=AE=80=E7=A7=B0=E8=8E=B7=E5=8F=96=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E4=BA=86=E5=BA=97=E9=93=BA=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E8=8E=B7=E5=8F=96=E6=96=B9=E5=BC=8F=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86=E7=9B=B8=E5=85=B3API=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/IndexController.php | 1 + app/api/logic/user/UserLogic.php | 1 + 2 files changed, 2 insertions(+) diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index 8804fcd31..40542ea25 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -227,6 +227,7 @@ class IndexController extends BaseApiController $list = [ 'id' => $find['id'], 'store_name' => $find['name'], + 'abbreviation' => $find['abbreviation'], ]; return $this->success('ok', $list); } diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index 661efec57..921b27604 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -129,6 +129,7 @@ class UserLogic extends BaseLogic $share_name=SystemStore::where('id',4)->value('abbreviation'); } $data['share_name']= $share_name.'No.'.preg_replace('/4/','*', $data['id']); + $data['no_code']= 'No.'.preg_replace('/4/','*', $data['id']); $data['system_store_id']=SystemStoreStaff::where('uid',$uid)->value('store_id'); $data['delivery_service_id']=DeliveryService::where('uid',$uid)->value('id'); From 915573615c15220e2c075bba0b0c40b5901ba85a Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 19 Aug 2024 20:13:34 +0800 Subject: [PATCH 7/9] =?UTF-8?q?feat(SystemStoreLists):=20=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=BA=86=E5=BA=97=E9=93=BA=E4=BF=A1=E6=81=AF=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=96=B9=E5=BC=8F=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E7=AE=80=E7=A7=B0=E8=8E=B7=E5=8F=96=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E6=9B=B4=E6=96=B0=E4=BA=86=E7=9B=B8=E5=85=B3API?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/store/SystemStoreLists.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/lists/store/SystemStoreLists.php b/app/api/lists/store/SystemStoreLists.php index c730b1ae7..9f52831f3 100644 --- a/app/api/lists/store/SystemStoreLists.php +++ b/app/api/lists/store/SystemStoreLists.php @@ -58,7 +58,7 @@ class SystemStoreLists extends BaseAdminDataLists implements ListsSearchInterfac $data = SystemStore::where($this->searchWhere)->where($where) ->field(['id', 'name', 'phone', 'detailed_address', 'image', 'is_show', 'day_time','is_store','latitude','longitude','day_start','day_end','is_store' - ,'is_send' + ,'is_send','abbreviation' ]) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) From c3cd0d6fe37dc85ce40e70ea129665c64a320c74 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 19 Aug 2024 20:42:31 +0800 Subject: [PATCH 8/9] =?UTF-8?q?feat(UserController,=20UserLogic):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E5=8F=82=E6=95=B0=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E5=92=8C=E7=AE=80=E7=A7=B0=E8=8E=B7=E5=8F=96=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E4=BA=86=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E8=8E=B7=E5=8F=96=E6=96=B9=E5=BC=8F=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86=E7=9B=B8=E5=85=B3API=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/user/UserController.php | 3 ++- app/api/logic/user/UserLogic.php | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/api/controller/user/UserController.php b/app/api/controller/user/UserController.php index 389a01ecf..d4ea0558e 100644 --- a/app/api/controller/user/UserController.php +++ b/app/api/controller/user/UserController.php @@ -68,7 +68,8 @@ class UserController extends BaseApiController // ] public function info() { - return $this->success('success', UserLogic::info($this->userId)); + $params=$this->request->post(); + return $this->success('success', UserLogic::info($this->userId,$params)); } // #[ diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index 921b27604..4c72f1b12 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -82,7 +82,7 @@ class UserLogic extends BaseLogic } - public static function info($uid) + public static function info($uid,$params) { $data = User::with(['userShip'])->where('id',$uid) ->field('id,avatar,real_name,nickname,account,mobile,sex,login_ip,now_money,total_recharge_amount,user_ship @@ -123,10 +123,15 @@ class UserLogic extends BaseLogic $number = UserSign::where('uid',$uid)->where(['status'=>0])->sum('number'); $data['number'] =bcadd($number,0,2); $data['GetNumber'] =bcadd($GetNumber,0,2); - if($data['store_id']){ - $share_name=SystemStore::where('id',$data['store_id'])->value('abbreviation'); + + if(isset($params['store_id']) && $params['store_id']>0){ + $share_name=SystemStore::where('id',$params['store_id'])->value('abbreviation'); }else{ - $share_name=SystemStore::where('id',4)->value('abbreviation'); + if($data['store_id']){ + $share_name=SystemStore::where('id',$data['store_id'])->value('abbreviation'); + }else{ + $share_name=SystemStore::where('id',4)->value('abbreviation'); + } } $data['share_name']= $share_name.'No.'.preg_replace('/4/','*', $data['id']); $data['no_code']= 'No.'.preg_replace('/4/','*', $data['id']); From 16ab967419ea9b14f276191a591b5d63709fcd5b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 19 Aug 2024 21:00:50 +0800 Subject: [PATCH 9/9] =?UTF-8?q?feat(UserLogic):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BA=86=E5=8F=82=E6=95=B0=E9=BB=98=E8=AE=A4=E5=80=BC=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=96=B9=E5=BC=8F=EF=BC=8C=E5=B9=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BA=86=E7=9B=B8=E5=85=B3API=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/user/UserLogic.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index 4c72f1b12..8e609df0d 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -82,7 +82,7 @@ class UserLogic extends BaseLogic } - public static function info($uid,$params) + public static function info($uid,$params=[]) { $data = User::with(['userShip'])->where('id',$uid) ->field('id,avatar,real_name,nickname,account,mobile,sex,login_ip,now_money,total_recharge_amount,user_ship