fix : place order coupon
This commit is contained in:
@@ -16,6 +16,7 @@ use App\Model\CouponTemplate;
|
||||
use App\Model\UserCoupon;
|
||||
use App\Service\Api\BaseService;
|
||||
use App\Service\ServiceTrait\Admin\Catering\PrintTrait;
|
||||
use App\Service\ServiceTrait\Api\CouponTrait;
|
||||
use App\Service\ServiceTrait\Api\OrderTrait;
|
||||
use App\Service\ServiceTrait\Common\CycleTrait;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
@@ -24,7 +25,7 @@ use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
abstract class BaseOrderService extends BaseService
|
||||
{
|
||||
use CycleTrait,OrderTrait,PrintTrait;
|
||||
use CycleTrait,OrderTrait,PrintTrait,CouponTrait;
|
||||
|
||||
/**
|
||||
* @var int 周期id
|
||||
@@ -100,7 +101,7 @@ abstract class BaseOrderService extends BaseService
|
||||
* 优惠券id
|
||||
* @var int
|
||||
*/
|
||||
protected int $couponId;
|
||||
protected int $couponId = 0;
|
||||
|
||||
/**
|
||||
* 地点id
|
||||
|
||||
@@ -121,6 +121,7 @@ class PlaceOrderService extends BaseOrderService
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws ErrException
|
||||
*/
|
||||
private function placeOrder(): void
|
||||
{
|
||||
@@ -133,12 +134,16 @@ class PlaceOrderService extends BaseOrderService
|
||||
|
||||
$this->insertOrderGoods();
|
||||
|
||||
$this->couponLock();
|
||||
|
||||
Db::commit();
|
||||
} catch (Exception $e){
|
||||
echo $e->getMessage();
|
||||
//回滚数据库 和 缓存
|
||||
Db::rollBack();
|
||||
$this->rollbackStock();
|
||||
|
||||
// $this->rollbackCouponLock();
|
||||
//意外抛出
|
||||
throw new ErrException($e->getMessage());
|
||||
}
|
||||
@@ -207,7 +212,7 @@ class PlaceOrderService extends BaseOrderService
|
||||
$orderInsertModel->is_refund_all = OrderCode::REFUND_NULL;
|
||||
$orderInsertModel->order_json = json_encode($this->orderRes);
|
||||
|
||||
if (!$orderInsertModel->save()) throw new Exception('下单失败');
|
||||
if (!$orderInsertModel->save()) throw new Exception('下单失败-01');
|
||||
|
||||
$this->orderId = $orderInsertModel->id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user