调整信用购订单列表查询

This commit is contained in:
luofei 2023-07-08 14:26:07 +08:00
parent 80b5274065
commit 451a8001b2
3 changed files with 6 additions and 7 deletions

View File

@ -60,6 +60,9 @@ class StoreGroupOrderDao extends BaseDao
public function search(array $where) public function search(array $where)
{ {
$storeOrderWhere = StoreOrder::where('activity_type', $where['product_type']); $storeOrderWhere = StoreOrder::where('activity_type', $where['product_type']);
if (isset($where['paid']) && $where['paid'] == 0) {
$storeOrderWhere->whereRaw("StoreGroupOrder.paid=0 or (StoreGroupOrder.paid=1 and StoreGroupOrder.pay_type=8)");
}
return StoreGroupOrder::hasWhere('orderList', $storeOrderWhere) return StoreGroupOrder::hasWhere('orderList', $storeOrderWhere)
->when(isset($where['paid']) && $where['paid'] !== '', function ($query) use ($where) { ->when(isset($where['paid']) && $where['paid'] !== '', function ($query) use ($where) {
$query->where('StoreGroupOrder.paid', $where['paid']); $query->where('StoreGroupOrder.paid', $where['paid']);

View File

@ -195,7 +195,7 @@ class StoreOrderRepository extends BaseRepository
//修改订单状态 //修改订单状态
Db::transaction(function () use ($subOrders, $is_combine, $groupOrder) { Db::transaction(function () use ($subOrders, $is_combine, $groupOrder) {
$time = date('Y-m-d H:i:s'); $time = date('Y-m-d H:i:s');
$groupOrder->paid = $groupOrder->pay_type == StoreGroupOrder::PAY_TYPE_CREDIT_BUY ? 0 : 1; $groupOrder->paid = 1;
$groupOrder->pay_time = $time; $groupOrder->pay_time = $time;
$groupOrder->is_combine = $is_combine; $groupOrder->is_combine = $is_combine;
$orderStatus = []; $orderStatus = [];
@ -2497,8 +2497,6 @@ class StoreOrderRepository extends BaseRepository
$merchantRepo = app()->make(MerchantRepository::class); $merchantRepo = app()->make(MerchantRepository::class);
$merchantRepo->unfreeze($groupOrder->interest->mer_id); $merchantRepo->unfreeze($groupOrder->interest->mer_id);
} }
$groupOrder->paid = 1;
$groupOrder->save();
} }
$groupOrder->interest->save(); $groupOrder->interest->save();
Db::commit(); Db::commit();

View File

@ -31,8 +31,8 @@ class OrderSettlePaySuccessListen implements ListenerInterface
try { try {
$orderSn = $data['order_sn']; $orderSn = $data['order_sn'];
$groupOrder = app()->make(StoreGroupOrderRepository::class)->getWhere(['group_order_sn' => $orderSn]); $groupOrder = app()->make(StoreGroupOrderRepository::class)->getWhere(['group_order_sn' => $orderSn]);
if (!$groupOrder || $groupOrder->paid == 1) { if (!$groupOrder || !$groupOrder->interest || $groupOrder->interest->status == StoreOrderInterest::STATUS_SETTLED) {
throw new \Exception('订单不存在或已支付'); throw new \Exception('订单无需结算');
} }
app()->make(MerchantRepository::class)->computedLockMoney($groupOrder->order); app()->make(MerchantRepository::class)->computedLockMoney($groupOrder->order);
$groupOrder->interest->status = StoreOrderInterest::STATUS_SETTLED; $groupOrder->interest->status = StoreOrderInterest::STATUS_SETTLED;
@ -46,8 +46,6 @@ class OrderSettlePaySuccessListen implements ListenerInterface
$merchantRepo = app()->make(MerchantRepository::class); $merchantRepo = app()->make(MerchantRepository::class);
$merchantRepo->unfreeze($groupOrder->interest->mer_id); $merchantRepo->unfreeze($groupOrder->interest->mer_id);
} }
$groupOrder->paid = 1;
$groupOrder->save();
Db::commit(); Db::commit();
} catch (\Exception $e) { } catch (\Exception $e) {
Db::rollback(); Db::rollback();