From fc5885494b993f219a6690a81940557123ae34b4 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Wed, 20 Mar 2024 10:22:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=AB=E7=A0=81=E6=94=AF=E4=BB=98=E4=B8=8D?= =?UTF-8?q?=E6=89=A3=E5=BA=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/store/coupon/StoreCouponUserDao.php | 4 +- .../order/StoreOrderCreateRepository.php | 17 ++++-- .../merchant/FinancialRecordRepository.php | 61 +++++++++++++++++++ app/controller/api/store/order/StoreOrder.php | 1 + 4 files changed, 76 insertions(+), 7 deletions(-) diff --git a/app/common/dao/store/coupon/StoreCouponUserDao.php b/app/common/dao/store/coupon/StoreCouponUserDao.php index de328e1c..7f9b6475 100644 --- a/app/common/dao/store/coupon/StoreCouponUserDao.php +++ b/app/common/dao/store/coupon/StoreCouponUserDao.php @@ -324,8 +324,8 @@ class StoreCouponUserDao extends BaseDao ] ]; foreach ($totalAmount as $item) { - if (isset($result[$item['type']])) { - $result[$item['type']]['total_amount']= bcadd($result[$item['type']]['total_amount'], $item['coupon_price'], 2); + if (isset($result[$item['coupon_type']])) { + $result[$item['coupon_type']]['total_amount']= bcadd($result[$item['coupon_type']]['total_amount'], $item['coupon_price'], 2); } } return array_values($result); diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 060d77c9..14aad678 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -42,6 +42,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository { public $saleType = Enum::SALE_TYPE_RETAIL; + public $isScanOrder = false; //是否扫码支付 public function v2CartIdByOrderInfo($user, array $cartId, array $takes = null, array $useCoupon = null, bool $useIntegral = false, int $addressId = null, $createOrder = false) { @@ -928,11 +929,13 @@ class StoreOrderCreateRepository extends StoreOrderRepository } } - if ($orderInfo['status'] == 'noDeliver') throw new ValidateException('部分商品不支持该区域'); - if ($orderInfo['status'] == 'noAddress') throw new ValidateException('请选择地址'); - if (!$order_model && $orderInfo['allow_address']) { - if (!$orderInfo['address']) throw new ValidateException('请选择正确的收货地址'); - if (!$orderInfo['address']['province_id']) throw new ValidateException('请完善收货地址信息'); + if (!$this->isScanOrder) { + if ($orderInfo['status'] == 'noDeliver') throw new ValidateException('部分商品不支持该区域'); + if ($orderInfo['status'] == 'noAddress') throw new ValidateException('请选择地址'); + if (!$order_model && $orderInfo['allow_address']) { + if (!$orderInfo['address']) throw new ValidateException('请选择正确的收货地址'); + if (!$orderInfo['address']['province_id']) throw new ValidateException('请完善收货地址信息'); + } } $orderType = $orderInfo['order_type']; if ($orderType && (count($orderInfo['order']) > 1 || ($orderType != 10 && count($orderInfo['order'][0]['list']) > 1))) { @@ -1173,6 +1176,10 @@ class StoreOrderCreateRepository extends StoreOrderRepository $uniqueList[$cart['productAttr']['product_id'] . $cart['productAttr']['unique']] = true; else throw new ValidateException('购物车商品信息重复'); + //线下扫码支付不扣库存 + if ($this->isScanOrder) { + continue; + } try { if ($cart['product_type'] == '1') { diff --git a/app/common/repositories/system/merchant/FinancialRecordRepository.php b/app/common/repositories/system/merchant/FinancialRecordRepository.php index 611c7243..edf312b7 100644 --- a/app/common/repositories/system/merchant/FinancialRecordRepository.php +++ b/app/common/repositories/system/merchant/FinancialRecordRepository.php @@ -34,6 +34,50 @@ class FinancialRecordRepository extends BaseRepository const FINANCIA_TYPE_SVIP = 'svip'; + const TYPE_NAME_MAP = [ + 'order' => '订单支付', + 'order_presell' => '预售订单(定金)', + 'order_refund' => '订单退款', + 'brokerage_one' => '一级分销佣金', + 'brokerage_two' => '二级分销佣金', + 'refund_brokerage_one' => '返还一级佣金', + 'refund_brokerage_two' => '返还二级佣金', + 'refund_order' => '订单退款', + 'order_platform_coupon' => '平台优惠券抵扣', + 'order_svip_coupon' => '超级会员优惠券抵扣', + 'commission_to_service_team' => '服务队佣金', + 'commission_to_platform' => '平台手续费', + 'commission_to_platform_refund' => '平台手续费退款', + 'platform_consumption' => '平台优惠', + 'platform_consumption_refund' => '平台优惠退款', + 'commission_to_promoter' => '推广人佣金', + 'commission_to_promoter_refund' => '推广人佣金退款', + 'auto_margin' => '商户保证金', + 'auto_margin_refund' => '商户保证金退款', + 'merchant_order' => '商户订单', + 'merchant_order_refund' => '商户订单退款', + 'supply_chain' => '供应链', + 'presell' => '预售订单(尾款)', + 'order_charge' => '手续费', + 'order_true' => '商户入账', + 'refund_charge' => '返还手续费', + 'refund_true' => '商户返还入账', + 'presell_charge' => '预售订单(手续费)', + 'presell_true' => '商户入账', + 'mer_presell' => '预售订单(总额)', + 'refund_platform_coupon' => '退回优惠券补贴', + 'commission_to_village' => '订单平台佣金', + 'commission_to_town' => '订单平台佣金', + 'commission_to_service_team_refund' => '退回平台佣金', + 'commission_to_village_refund' => '退回平台佣金', + 'commission_to_town_refund' => '退回平台佣金', + 'commission_to_entry_merchant' => '订单平台佣金',//入口店铺佣金 + 'commission_to_cloud_warehouse' => '订单平台佣金',//云仓佣金 + 'commission_to_entry_merchant_refund' => '退回平台佣金', + 'commission_to_cloud_warehouse_refund' => '退回平台佣金', + 'first_order_commission' => '首单拉新', + ]; + public function __construct(FinancialRecordDao $dao) { $this->dao = $dao; @@ -53,6 +97,12 @@ class FinancialRecordRepository extends BaseRepository $query = $this->dao->search($where)->order('create_time DESC'); $count = $query->count(); $list = $query->page($page, $limit)->select(); + foreach ($list as &$item) { + if (!empty($where['mer_id'])) { + $item['financial_pm'] = $item['financial_pm'] == 0 ? 1 : 0; + } + $item['financial_type_cn'] = $this->getFinancialTypeName($item['financial_type']); + } return compact('count', 'list'); } @@ -676,4 +726,15 @@ class FinancialRecordRepository extends BaseRepository } return compact('count','list'); } + + /** + * 获取财务类型 + * @param $type + * @return string + */ + public function getFinancialTypeName($type) + { + return self::TYPE_NAME_MAP[$type] ?? ''; + } + } diff --git a/app/controller/api/store/order/StoreOrder.php b/app/controller/api/store/order/StoreOrder.php index 23aad486..282015eb 100644 --- a/app/controller/api/store/order/StoreOrder.php +++ b/app/controller/api/store/order/StoreOrder.php @@ -109,6 +109,7 @@ class StoreOrder extends BaseController // return app('json')->fail('请选择地址'); $groupOrder = app()->make(LockService::class)->exec('order.create', function () use ($key, $orderCreateRepository, $receipt_data, $mark, $extend, $cartId, $payType, $takes, $couponIds, $useIntegral, $addressId, $post) { + $orderCreateRepository->isScanOrder = (int)$this->request->param('source') == 999; return $orderCreateRepository->v2CreateOrder($key, array_search($payType, StoreOrderRepository::PAY_TYPE), $this->request->userInfo(), $cartId, $extend, $mark, $receipt_data, $takes, $couponIds, $useIntegral, $addressId, $post); });