diff --git a/app/common/repositories/store/order/StoreRefundOrderRepository.php b/app/common/repositories/store/order/StoreRefundOrderRepository.php index 0ff05ed4..5ebbed86 100644 --- a/app/common/repositories/store/order/StoreRefundOrderRepository.php +++ b/app/common/repositories/store/order/StoreRefundOrderRepository.php @@ -15,6 +15,7 @@ namespace app\common\repositories\store\order; use app\common\dao\store\order\StoreRefundOrderDao; +use app\common\model\store\order\StoreGroupOrder; use app\common\model\store\order\StoreOrder; use app\common\model\store\order\StoreRefundOrder; use app\common\model\system\merchant\FinancialRecord; @@ -268,6 +269,9 @@ class StoreRefundOrderRepository extends BaseRepository */ public function refunds(StoreOrder $order, array $ids, $uid, array $data) { + if ($order->pay_type == StoreGroupOrder::PAY_TYPE_CREDIT_BUY && $order->status == 2) { + throw new ValidateException('已收货的订单不支持退款'); + } $orderId = $order->order_id; $products = app()->make(StoreOrderProductRepository::class)->userRefundProducts($ids, $uid, $orderId); if (!$products || count($ids) != count($products)) @@ -331,6 +335,9 @@ class StoreRefundOrderRepository extends BaseRepository $data['integral'] = $totalIntegral; $data['platform_refund_price'] = $totalPlatformRefundPrice; $data['refund_postage'] = $totalPostage; + if ($order['pay_type'] == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) { + $data['refund_price'] = 0; + } return Db::transaction(function () use ($refundProduct, $data, $products, $order, &$refund_order_id) { event('refund.creates.before', compact('data')); @@ -394,6 +401,9 @@ class StoreRefundOrderRepository extends BaseRepository */ public function refund(StoreOrder $order, $productId, $num, $uid, array $data) { + if ($order->pay_type == StoreGroupOrder::PAY_TYPE_CREDIT_BUY && $order->status == 2) { + throw new ValidateException('已收货的订单不支持退款'); + } $orderId = $order->order_id; //TODO 订单状态生成佣金 $product = app()->make(StoreOrderProductRepository::class)->userRefundProducts([$productId], $uid, $orderId); @@ -464,6 +474,9 @@ class StoreRefundOrderRepository extends BaseRepository $data['refund_num'] = $num; $data['extension_one'] = $total_extension_one; $data['extension_two'] = $total_extension_two; + if ($order['pay_type'] == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) { + $data['refund_price'] = 0; + } return Db::transaction(function () use ($order, $data, $product, $productId, $num) { event('refund.create.before', compact('data')); diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index 6c4453d2..210c55b7 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -2280,9 +2280,9 @@ class ProductRepository extends BaseRepository $supplierMerId = 0; if (empty($params['product_id']) && !empty($params['order_product_id'])) { //有商品无规格或者无商品无规格,导入商品和规格 - $product = Db::name('store_product')->where('source_product_id', $params['order_product_id'])->where('mer_id', $merId)->find(); + $product = $this->getWhere(['source_product_id' => $params['order_product_id'], 'mer_id' => $merId]); if (!empty($product)) { - $unique = $this->importAttrValue($params['order_product_id'], $product, $params['order_unique']); + $unique = $this->importAttrValue($params['order_product_id'], $product->toArray(), $params['order_unique']); if (!$unique) { throw new \Exception('商品规格导入出错', 500); } diff --git a/app/controller/api/store/merchant/Merchant.php b/app/controller/api/store/merchant/Merchant.php index 9fb63d5d..1cc30a6e 100644 --- a/app/controller/api/store/merchant/Merchant.php +++ b/app/controller/api/store/merchant/Merchant.php @@ -250,7 +250,7 @@ class Merchant extends BaseController } public function apply($merId){ - $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $merId])->field('uid,mer_id,mer_name,mer_money,financial_bank,financial_wechat,financial_alipay,financial_type,is_frozen')->find(); + $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $merId])->field('uid,mer_id,mer_name,mer_money,financial_bank,financial_wechat,financial_alipay,financial_type')->find(); if (($msg = $this->checkAuth($merchant)) !== true) { return app('json')->fail($msg); } @@ -283,7 +283,7 @@ class Merchant extends BaseController public function createApply($merId) { $data = $this->request->param(['extract_money','financial_type', 'financial_bank_name', 'financial_bank_bank', 'financial_bank_code', 'financial_bank_branch']); - $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $merId])->field('reg_admin_id,uid,mer_id,mer_name,mer_money,financial_bank,financial_wechat,financial_alipay,financial_type,is_frozen')->find(); + $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $merId])->field('reg_admin_id,uid,mer_id,mer_name,mer_money,financial_bank,financial_wechat,financial_alipay,financial_type')->find(); if (($msg = $this->checkAuth($merchant)) !== true) { return app('json')->fail($msg); } @@ -302,7 +302,7 @@ class Merchant extends BaseController public function listApply($merId) { - $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $merId])->field('reg_admin_id,uid,mer_id,mer_name,mer_money,financial_bank,financial_wechat,financial_alipay,financial_type,is_frozen')->find(); + $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $merId])->field('reg_admin_id,uid,mer_id,mer_name,mer_money,financial_bank,financial_wechat,financial_alipay,financial_type')->find(); if (($msg = $this->checkAuth($merchant)) !== true) { return app('json')->fail($msg); } @@ -315,7 +315,7 @@ class Merchant extends BaseController public function account($merId) { - $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $merId])->field('uid,mer_id,mer_name,mer_money,financial_bank,financial_wechat,financial_alipay,financial_type,is_frozen')->find(); + $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $merId])->field('uid,mer_id,mer_name,mer_money,financial_bank,financial_wechat,financial_alipay,financial_type')->find(); if (($msg = $this->checkAuth($merchant)) !== true) { return app('json')->fail($msg); } @@ -332,7 +332,7 @@ class Merchant extends BaseController { $data = $this->request->param(['name','bank','bank_code','financial_type']); app()->make(MerchantFinancialAccountValidate::class)->check($data); - $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $merId])->field('uid,mer_id,mer_name,mer_money,financial_bank,financial_wechat,financial_alipay,financial_type,is_frozen')->find(); + $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $merId])->field('uid,mer_id,mer_name,mer_money,financial_bank,financial_wechat,financial_alipay,financial_type')->find(); if (($msg = $this->checkAuth($merchant)) !== true) { return app('json')->fail($msg); } diff --git a/app/listener/OrderCreate.php b/app/listener/OrderCreate.php index 4900896b..4d366778 100644 --- a/app/listener/OrderCreate.php +++ b/app/listener/OrderCreate.php @@ -4,6 +4,7 @@ declare (strict_types=1); namespace app\listener; +use app\common\model\store\order\StoreGroupOrder; use app\common\model\system\merchant\Merchant; use app\common\repositories\store\order\StoreOrderInterestRepository; @@ -17,6 +18,9 @@ class OrderCreate { $groupOrder = $event['groupOrder']; $order = $groupOrder->orderList[0]; + if ($order['pay_type'] != StoreGroupOrder::PAY_TYPE_CREDIT_BUY && $order['activity_type'] != 98) { + return true; + } /** @var StoreOrderInterestRepository $storeOrderInterestRepository */ $storeOrderInterestRepository = app()->make(StoreOrderInterestRepository::class); $merchantId = Merchant::where('uid', $groupOrder['uid'])->value('mer_id');