ShopWind电商系统商家可以发布相应的优惠券给买领券,买家领券优惠券后到店铺中购买商品,符合优惠券的使用条件可以在订单中使用优惠券抵扣相应面额的货款。
问题描叙
用户领一张优惠券可以在多个订单中使用,使用后不失效的问题。
解决办法
打开文件common/business/BaseOrder.php , 做如下修改
查询代码
public function updateCouponRemainTimes($result = array(), $coupon = array())
{
foreach($result as $store_id => $order_id) {
if(isset($coupon[$store_id]['coupon_sn'])) {
$query = CouponsnModel::find()->select('remain_times')->where(['coupon_sn' => $coupon[$store_id]['coupon_sn']])->one(),
if ($query->remain_times > 0) {
$query->updateCounters(['remain_times' => -1]),
}
}
}
}
修改为
public function updateCouponRemainTimes($result = array(), $coupon = array())
{
foreach($result as $store_id => $order_id) {
if(isset($coupon[$store_id]['coupon_sn'])) {
$query = CouponsnModel::find()->where(['coupon_sn' => $coupon[$store_id]['coupon_sn']])->one(),
if ($query->remain_times > 0) {
$query->updateCounters(['remain_times' => -1]),
}
}
}
}