10、问诊订单退款
11、药品订单退款 12、问诊订单模拟退款 13、药品订单模拟退款
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Model\OrderInquiryCoupon;
|
||||
use App\Model\Product;
|
||||
use App\Model\UserCoupon;
|
||||
use App\Utils\Log;
|
||||
|
||||
/**
|
||||
* 用户优惠卷
|
||||
@@ -209,4 +211,44 @@ class UserCouponService extends BaseService
|
||||
|
||||
return $selected_coupons;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退还用户优惠卷
|
||||
* @param string|int $user_coupon_id
|
||||
* @return bool
|
||||
*/
|
||||
public function returnUserCoupon(string|int $user_coupon_id): bool
|
||||
{
|
||||
try {
|
||||
// 获取用户优惠卷数据
|
||||
$params = array();
|
||||
$params['user_coupon_id'] = $user_coupon_id;
|
||||
$user_coupon = UserCoupon::getOne($params);
|
||||
if (empty($user_coupon)) {
|
||||
// 无该优惠卷数据,无需处理
|
||||
return true;
|
||||
}
|
||||
|
||||
// 恢复优惠卷
|
||||
$data = array();
|
||||
|
||||
// 检测优惠卷过期时间。判断是否需要退还
|
||||
if (strtotime($user_coupon['valid_end_time']) <= time()) {
|
||||
// 超出过期时间,置为已过期
|
||||
$data['user_coupon_status'] = 3;
|
||||
} else {
|
||||
$data['user_coupon_status'] = 0;
|
||||
$data['coupon_use_date'] = null;
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['user_coupon_id'] = $user_coupon_id;
|
||||
UserCoupon::edit($params, $data);
|
||||
}catch (\Throwable $e){
|
||||
Log::getInstance("UserCouponService-returnUserCoupon")->error($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user