信用购订单添加确认接单

This commit is contained in:
luofei 2023-07-04 11:13:39 +08:00
parent 0b4dcf19ea
commit 01df202cb7
4 changed files with 56 additions and 2 deletions

View File

@ -26,6 +26,9 @@ use app\common\repositories\store\MerchantTakeRepository;
class StoreOrder extends BaseModel
{
const STATUS_WAIT_CONFIRM = 12; //待确认
const STATUS_WAIT_PAY = 0; //待支付
public static function tablePk(): ?string
{
return 'order_id';

View File

@ -4,6 +4,7 @@ namespace app\common\repositories\store\order;
use app\common\dao\store\order\StoreCartDao;
use app\common\model\store\order\StoreGroupOrder;
use app\common\model\store\order\StoreOrder;
use app\common\repositories\store\coupon\StoreCouponRepository;
use app\common\repositories\store\coupon\StoreCouponUserRepository;
use app\common\repositories\store\product\ProductAssistSkuRepository;
@ -1219,6 +1220,9 @@ class StoreOrderCreateRepository extends StoreOrderRepository
$orderProduct = [];
$orderStatus = [];
foreach ($orderList as $order) {
if ($order['pay_type'] == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) {
$order['status'] = StoreOrder::STATUS_WAIT_CONFIRM;
}
$cartInfo = $order['cartInfo'];
unset($order['cartInfo']);
//创建子订单

View File

@ -2495,4 +2495,36 @@ class StoreOrderRepository extends BaseRepository
}
}
/**
* 确认接单
* @param $user
* @param $id
* @return void
* @throws Exception
*/
public function confirm($user, $id)
{
/** @var StoreGroupOrderRepository $groupOrderRepository */
$groupOrderRepository = app()->make(StoreGroupOrderRepository::class);
$groupOrderRepository->getAll = true;
Db::startTrans();
try {
$groupOrder = $groupOrderRepository->detail($user['uid'], $id, false);
if ($groupOrder->pay_type != StoreGroupOrder::PAY_TYPE_CREDIT_BUY) {
throw new Exception('订单类型错误');
}
$order = $groupOrder->orderList[0];
if ($order->status != StoreOrder::STATUS_WAIT_CONFIRM) {
throw new Exception('订单状态错误');
}
$order->status = StoreOrder::STATUS_WAIT_PAY;
$order->save();
Db::commit();
} catch (\Exception $e) {
Db::rollback();
throw new Exception($e->getMessage());
}
}
}

View File

@ -106,11 +106,11 @@ class StoreOrder extends BaseController
return $orderCreateRepository->v2CreateOrder(array_search($payType, StoreOrderRepository::PAY_TYPE), $this->request->userInfo(), $cartId, $extend, $mark, $receipt_data, $takes, $couponIds, $useIntegral, $addressId, $post);
});
if ($groupOrder['pay_price'] == 0 || $groupOrder['pay_type'] == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) {
if ($groupOrder['pay_price'] == 0) {
$this->repository->paySuccess($groupOrder);
return app('json')->status('success', '支付成功', ['order_id' => $groupOrder['group_order_id']]);
}
if ($isPc) {
if ($isPc || $groupOrder['pay_type'] == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) {
return app('json')->success(['order_id' => $groupOrder->group_order_id]);
}
try {
@ -316,4 +316,19 @@ class StoreOrder extends BaseController
}
}
/**
* 确认接单
* @return mixed
*/
public function confirm()
{
$id = $this->request->param('id/d');
try {
$this->repository->confirm($this->request->userInfo(), $id);
return app('json')->success('success');
} catch (\Exception $e) {
return app('json')->fail($e->getMessage());
}
}
}