发放购买服务包的关联优惠卷修改
This commit is contained in:
parent
11b28c7ab0
commit
70ef1ae117
@ -146,7 +146,7 @@ class UserCoupon extends Model
|
|||||||
->whereIn("application_scope",[1,3,4,5])
|
->whereIn("application_scope",[1,3,4,5])
|
||||||
->where(function ($query) use ($coupon_product_datas) {
|
->where(function ($query) use ($coupon_product_datas) {
|
||||||
foreach ($coupon_product_datas as $coupon_product_data){
|
foreach ($coupon_product_datas as $coupon_product_data){
|
||||||
$query->orwhere("product_id","like",'%' . $coupon_product_data['product_id'] . '%');
|
$query->orwhere("product_id","=",$coupon_product_data['product_id']);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|||||||
@ -68,6 +68,7 @@ class CouponService extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 判断该优惠卷过期时间
|
// 判断该优惠卷过期时间
|
||||||
|
if (!empty($coupon['valid_type'])){
|
||||||
if ($coupon['valid_type'] == 1){
|
if ($coupon['valid_type'] == 1){
|
||||||
// 绝对时效
|
// 绝对时效
|
||||||
$valid_end_time = strtotime($coupon['valid_end_time']);
|
$valid_end_time = strtotime($coupon['valid_end_time']);
|
||||||
@ -78,6 +79,7 @@ class CouponService extends BaseService
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 添加用户优惠卷表
|
// 添加用户优惠卷表
|
||||||
@ -131,7 +133,8 @@ class CouponService extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 添加优惠卷过期队列
|
// 添加优惠卷过期队列
|
||||||
$valid_end_time = strtotime($user_coupon->valid_end_time);
|
if (!empty($user_coupon['valid_start_time']) && !empty($user_coupon['valid_end_time'])){
|
||||||
|
$valid_end_time = strtotime($user_coupon['valid_start_time']);
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
$data['user_coupon_id'] = $user_coupon['user_coupon_id'];
|
$data['user_coupon_id'] = $user_coupon['user_coupon_id'];
|
||||||
@ -144,6 +147,7 @@ class CouponService extends BaseService
|
|||||||
if (!$res) {
|
if (!$res) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}catch (\Throwable $e){
|
}catch (\Throwable $e){
|
||||||
Log::getInstance("CouponService-GrantUserCoupon")->error($e->getMessage());
|
Log::getInstance("CouponService-GrantUserCoupon")->error($e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
@ -151,6 +155,7 @@ class CouponService extends BaseService
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// 添加优惠卷即将过期提醒队列
|
// 添加优惠卷即将过期提醒队列
|
||||||
|
if (!empty($user_coupon['valid_start_time']) && !empty($user_coupon['valid_end_time']) && isset($time)){
|
||||||
$time = floor($time * 0.75);
|
$time = floor($time * 0.75);
|
||||||
|
|
||||||
// 时间低于5小时,不进行过期提醒
|
// 时间低于5小时,不进行过期提醒
|
||||||
@ -167,6 +172,7 @@ class CouponService extends BaseService
|
|||||||
// 通知-患者-优惠卷发放
|
// 通知-患者-优惠卷发放
|
||||||
$MessagePush = new MessagePush($user_id);
|
$MessagePush = new MessagePush($user_id);
|
||||||
$MessagePush->patientDistributeCoupon($coupon['coupon_name']);
|
$MessagePush->patientDistributeCoupon($coupon['coupon_name']);
|
||||||
|
}
|
||||||
}catch (\Throwable $e){
|
}catch (\Throwable $e){
|
||||||
Log::getInstance("CouponService-GrantUserCoupon")->error($e->getMessage());
|
Log::getInstance("CouponService-GrantUserCoupon")->error($e->getMessage());
|
||||||
}
|
}
|
||||||
@ -202,9 +208,11 @@ class CouponService extends BaseService
|
|||||||
/**
|
/**
|
||||||
* 发放购买服务包的关联优惠卷
|
* 发放购买服务包的关联优惠卷
|
||||||
* @param string $user_id 用户id
|
* @param string $user_id 用户id
|
||||||
|
* @param string $start_time 开始使用时间
|
||||||
|
* @param string $finish_time 结束有效时间
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function GrantBuyOrderServicePackageCoupon(string $user_id): bool
|
public function GrantBuyOrderServicePackageCoupon(string $user_id,string $start_time,string $finish_time): bool
|
||||||
{
|
{
|
||||||
// 获取购买服务包的用户可领取的优惠卷列表
|
// 获取购买服务包的用户可领取的优惠卷列表
|
||||||
$coupon = Coupon::getOrderServicePackageCouponList();
|
$coupon = Coupon::getOrderServicePackageCouponList();
|
||||||
@ -219,6 +227,17 @@ class CouponService extends BaseService
|
|||||||
// 发放失败
|
// 发放失败
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 增加优惠卷有效期
|
||||||
|
$params = array();
|
||||||
|
$params['user_id'] = $user_id;
|
||||||
|
$params['coupon_id'] = $value['coupon_id'];
|
||||||
|
$params['user_coupon_status'] = 0;
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
$data['valid_start_time'] = $start_time;
|
||||||
|
$data['valid_end_time'] = $finish_time;
|
||||||
|
UserCoupon::edit($params,$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -135,6 +135,7 @@ class UserCouponService extends BaseService
|
|||||||
|
|
||||||
// 处理优惠卷数量限制问题
|
// 处理优惠卷数量限制问题
|
||||||
foreach ($coupons as $key => $coupon) {
|
foreach ($coupons as $key => $coupon) {
|
||||||
|
// 处理数量优惠卷
|
||||||
if ($coupon['coupon_type'] == 3 && !empty($coupon['product_id'])){
|
if ($coupon['coupon_type'] == 3 && !empty($coupon['product_id'])){
|
||||||
// 数量是否足够标识字段
|
// 数量是否足够标识字段
|
||||||
$quantity_quantity = 0;
|
$quantity_quantity = 0;
|
||||||
@ -161,16 +162,18 @@ class UserCouponService extends BaseService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理满减金额问题
|
// 处理满减金额优惠卷
|
||||||
if ($coupon['coupon_type'] == 2 && !empty($coupon['product_id'])){
|
if ($coupon['coupon_type'] == 2){
|
||||||
// 可共用一个优惠卷的商品金额问题
|
// 可共用一个优惠卷的商品金额问题
|
||||||
$product_price = 0;
|
$product_price = 0;
|
||||||
|
|
||||||
foreach ($coupon_product_datas as $coupon_product_data) {
|
foreach ($coupon_product_datas as $coupon_product_data) {
|
||||||
// 如该优惠卷不包含此商品,跳过
|
// 如该优惠卷不包含此商品,跳过
|
||||||
|
if (!empty($coupon['product_id'])){
|
||||||
if (!str_contains($coupon['product_id'], $coupon_product_data['product_id'])) {
|
if (!str_contains($coupon['product_id'], $coupon_product_data['product_id'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$product_price = bcadd($product_price,
|
$product_price = bcadd($product_price,
|
||||||
bcmul( // 商品价格*数量
|
bcmul( // 商品价格*数量
|
||||||
|
|||||||
@ -1911,7 +1911,7 @@ class UserDoctorService extends BaseService
|
|||||||
if (count($order_service_package_inquiry) <= 1){
|
if (count($order_service_package_inquiry) <= 1){
|
||||||
// 发放优惠卷
|
// 发放优惠卷
|
||||||
$CouponService = new CouponService();
|
$CouponService = new CouponService();
|
||||||
$res = $CouponService->GrantBuyOrderServicePackageCoupon($order_inquiry['user_id']);
|
$res = $CouponService->GrantBuyOrderServicePackageCoupon($order_inquiry['user_id'],$start_time,$finish_time);
|
||||||
if (!$res) {
|
if (!$res) {
|
||||||
Db::rollBack();
|
Db::rollBack();
|
||||||
return fail(HttpEnumCode::HTTP_ERROR, "接诊失败");
|
return fail(HttpEnumCode::HTTP_ERROR, "接诊失败");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user