From 7e5e812ad35c3a026a76b6406f692a32c6ae697a Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Mon, 8 Apr 2024 13:53:55 +0800 Subject: [PATCH] 1 --- app/api/service/order/Checkout.php | 38 ++++++++++++++++++++---------- app/store/controller/Order.php | 10 +++++++- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/app/api/service/order/Checkout.php b/app/api/service/order/Checkout.php index 8f0bfbb8..9a7109f8 100644 --- a/app/api/service/order/Checkout.php +++ b/app/api/service/order/Checkout.php @@ -12,28 +12,29 @@ declare (strict_types=1); namespace app\api\service\order; -use app\api\model\User as UserModel; +use app\api\model\dealer\Order as DealerOrderModel; use app\api\model\Goods as GoodsModel; use app\api\model\Order as OrderModel; use app\api\model\Setting as SettingModel; +use app\api\model\store\Module as StoreModuleModel; use app\api\model\store\Shop as ShopModel; +use app\api\model\User as UserModel; use app\api\model\UserCoupon as UserCouponModel; -use app\api\model\store\Module as StoreModuleModel; -use app\api\model\dealer\Order as DealerOrderModel; -use app\api\service\User as UserService; -use app\api\service\user\Grade as UserGradeService; +use app\api\model\wholesaler\Apply; use app\api\service\coupon\GoodsDeduct as GoodsDeductService; -use app\api\service\points\GoodsDeduct as PointsDeductService; use app\api\service\order\source\checkout\Factory as CheckoutFactory; +use app\api\service\points\GoodsDeduct as PointsDeductService; +use app\api\service\User as UserService; +use app\api\service\user\Grade as UserGradeService; +use app\common\enum\order\DeliveryType as DeliveryTypeEnum; +use app\common\enum\order\OrderSource as OrderSourceEnum; +use app\common\enum\order\OrderStatus as OrderStatusEnum; use app\common\enum\order\OrderType; use app\common\enum\Setting as SettingEnum; -use app\common\enum\order\OrderStatus as OrderStatusEnum; -use app\common\enum\order\OrderSource as OrderSourceEnum; -use app\common\enum\order\DeliveryType as DeliveryTypeEnum; +use app\common\library\helper; use app\common\service\BaseService; use app\common\service\delivery\Express as ExpressService; use app\common\service\goods\source\Factory as StockFactory; -use app\common\library\helper; use cores\exception\BaseException; /** @@ -186,7 +187,7 @@ class Checkout extends BaseService $this->setError("您的收货地址不在商品 [{$value['goods_name']}] 的销售区域内"); } } - + // 验证商品状态, 是否允许购买 $this->validateGoodsList(); // 订单商品总数量 @@ -761,6 +762,17 @@ class Checkout extends BaseService return true; } + private function checkoutAddress($address) + { + $info = Apply::detail(['user_id' => $this->user['user_id']]); + if (!empty($info)) { + $info = $info->toArray(); + if ($info['province_id'] == $address['province_id'] && $info['city_id'] == $address['city_id']) { + OrderModel::update(['address_match' => 20], ['order_id' => $this->model['order_id']]); + } + } + } + /** * 保存订单数据 (实物商品) * @param $order @@ -771,6 +783,8 @@ class Checkout extends BaseService if ($order['delivery'] == DeliveryTypeEnum::EXPRESS) { // 记录收货地址 $this->saveOrderAddress($order['address']); + //判断地址与申请采购商时地址否匹配 + $this->checkoutAddress($order['address']); } elseif ($order['delivery'] == DeliveryTypeEnum::EXTRACT) { // 记录自提信息 $this->saveOrderExtract($this->param['linkman'], $this->param['phone']); @@ -884,7 +898,7 @@ class Checkout extends BaseService { $totalCostPrice = 0; foreach ($goodsList as $goods) { - $totalCostPrice +=$goods['skuInfo']['cost_price']; + $totalCostPrice += $goods['skuInfo']['cost_price']; } return helper::number2($totalCostPrice); } diff --git a/app/store/controller/Order.php b/app/store/controller/Order.php index ebfad295..a32fba65 100644 --- a/app/store/controller/Order.php +++ b/app/store/controller/Order.php @@ -35,6 +35,7 @@ class Order extends Controller $data = $result->items(); if (!empty($data)) { foreach ($data as $key => $value) { + $data[$key]['address_match_text'] = '--'; $copy_text = "订单号:{$value['order_no']}\n"; foreach ($value['goods'] as $good) { $copy_text .= "商品名称:{$good['goods_name']}\n"; @@ -56,6 +57,13 @@ class Order extends Controller $copy_text .= "收件地址:$address{$value['address']['detail']}\n"; } $data[$key]['copy_text'] = $copy_text; + if ($value['delivery_type'] == 10) { + if ($value['address_match'] == 20) { + $data[$key]['address_match_text'] = '匹配'; + } else { + $data[$key]['address_match_text'] = '不匹配'; + } + } } } $list['current_page'] = $result->currentPage(); @@ -64,7 +72,7 @@ class Order extends Controller $list['data'] = $data; return $this->renderSuccess(compact('dataType', 'list')); } - + /** * 订单详情