作者 何书鹏

赠送积分

... ... @@ -400,6 +400,14 @@ class Cart extends Api
(new Goods)->allowField(true)->isUpdate()->saveAll($goodsSave);
// 更新商品规格库存
(new GoodsSpec)->allowField(true)->isUpdate()->saveAll($goodsSpecSave);
// 订单支付-赠送积分
if($order['order_price'] > 0){
$sendscore = config('site.sendscore'); // 消费多少元赠送1积分
$score = bcdiv($order['order_price'],$sendscore); // 赠送积分
if($score >= 1){
\app\common\model\User::score($score,$order['user_id'],'订单支付-赠送积分');
}
}
return true;
}
}
\ No newline at end of file
... ...
... ... @@ -274,7 +274,7 @@ class Cart extends Model
$score['use_score'] = $user['score'];
}else{
$score['score_price'] = $sub_price;
$score['use_score'] = bcmul($sub_price,$scoreprice,0);
$score['use_score'] = bcmul($sub_price,$scoreprice);
}
}
// 优惠金额
... ...
... ... @@ -157,8 +157,8 @@ class Order extends Model
UserCoupon::where('id',$order['coupon']['user_coupon_id'])->setField('status','2');
}
// 用掉积分
if($order['score']['score'] > 0){
User::score(-$order['score']['score'],$user_id,'订单支付');
if($order['score']['use_score'] > 0){
User::score(-$order['score']['use_score'],$user_id,'订单支付-使用积分');
}
Db::commit();
return true;
... ...