Browse Source

自增或插入

master
parent
commit
240f58c43e
  1. 9
      app/Service/CouponRebateService.php

9
app/Service/CouponRebateService.php

@ -174,7 +174,6 @@ class CouponRebateService implements CouponRebateServiceInterface
*/ */
public function couponRebate($order_id) public function couponRebate($order_id)
{ {
/* 判断优惠券类型是否为转发活动优惠券 */ /* 判断优惠券类型是否为转发活动优惠券 */
$coupon = Db::table('ims_system_coupon_user_receive as r') $coupon = Db::table('ims_system_coupon_user_receive as r')
->leftjoin('ims_system_coupon_user_use as u', 'u.user_receive_id', '=', 'r.id') ->leftjoin('ims_system_coupon_user_use as u', 'u.user_receive_id', '=', 'r.id')
@ -212,7 +211,7 @@ class CouponRebateService implements CouponRebateServiceInterface
* 否则新增一条返券记录 * 否则新增一条返券记录
*/ */
$nowTime = time(); $nowTime = time();
$res = Db::table('ims_system_coupon_user_receive')->updateOrInsert(
$res = Db::table('ims_system_coupon_user_receive')->updateOrIncrement(
[ [
'system_coupon_user_id' => $coupon->system_coupon_id, 'system_coupon_user_id' => $coupon->system_coupon_id,
'user_id' => $coupon->send_user_id, 'user_id' => $coupon->send_user_id,
@ -222,11 +221,13 @@ class CouponRebateService implements CouponRebateServiceInterface
[ [
'order_main_id' => $order_id, 'order_main_id' => $order_id,
'receive_time' => $nowTime, 'receive_time' => $nowTime,
'number' => 1,
'number_remain' => 1,
'update_time' => $nowTime, 'update_time' => $nowTime,
'created_at' => $nowTime, 'created_at' => $nowTime,
'updated_at' => $nowTime, 'updated_at' => $nowTime,
],
[
'number' => 1,
'number_remain' => 1,
] ]
); );
// if ($res) { // if ($res) {

Loading…
Cancel
Save