服务包订单支付成功回调,增加了发放优惠卷
This commit is contained in:
parent
f8cabb455a
commit
cb95bde20c
@ -50,6 +50,7 @@ use App\Model\UserSystem;
|
|||||||
use App\Model\VideoRecord;
|
use App\Model\VideoRecord;
|
||||||
use App\Model\VideoReservation;
|
use App\Model\VideoReservation;
|
||||||
use App\Services\BaseService;
|
use App\Services\BaseService;
|
||||||
|
use App\Services\CouponService;
|
||||||
use App\Services\ImService;
|
use App\Services\ImService;
|
||||||
use App\Services\InquiryService;
|
use App\Services\InquiryService;
|
||||||
use App\Services\MessagePush;
|
use App\Services\MessagePush;
|
||||||
@ -2736,6 +2737,15 @@ class CallBackController extends AbstractController
|
|||||||
return $server->serve();
|
return $server->serve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 发放优惠卷
|
||||||
|
$CouponService = new CouponService();
|
||||||
|
$res = $CouponService->GrantBuyOrderServicePackageCoupon($order_service_package['user_id']);
|
||||||
|
if (!$res) {
|
||||||
|
Db::rollBack();
|
||||||
|
Log::getInstance("CallBack-wxPayServiceSuccess")->error("订单创建失败");
|
||||||
|
return $server->serve();
|
||||||
|
}
|
||||||
|
|
||||||
// 加入未接诊取消订单延迟队列
|
// 加入未接诊取消订单延迟队列
|
||||||
$time = 60 * 60 * 24;
|
$time = 60 * 60 * 24;
|
||||||
if (\Hyperf\Config\config('app_env') == "dev"){
|
if (\Hyperf\Config\config('app_env') == "dev"){
|
||||||
|
|||||||
@ -6,6 +6,7 @@ namespace App\Model;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
use Hyperf\Database\Model\Collection;
|
use Hyperf\Database\Model\Collection;
|
||||||
use Hyperf\Snowflake\Concern\Snowflake;
|
use Hyperf\Snowflake\Concern\Snowflake;
|
||||||
|
|
||||||
@ -37,8 +38,8 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
|||||||
* @property int $reissue_interval_days 确认收货后的再次发放间隔天数(如果设置为 0,则表示不再次发放。当适用范围为商品时生效)
|
* @property int $reissue_interval_days 确认收货后的再次发放间隔天数(如果设置为 0,则表示不再次发放。当适用范围为商品时生效)
|
||||||
* @property int $is_reissuable_after_expire 过期之后是否允许再次发放(0:否 1:是)
|
* @property int $is_reissuable_after_expire 过期之后是否允许再次发放(0:否 1:是)
|
||||||
* @property int $is_popup 是否首页弹窗(0:否 1:是)
|
* @property int $is_popup 是否首页弹窗(0:否 1:是)
|
||||||
* @property \Carbon\Carbon $created_at 创建时间
|
* @property Carbon $created_at 创建时间
|
||||||
* @property \Carbon\Carbon $updated_at 修改时间
|
* @property Carbon $updated_at 修改时间
|
||||||
*/
|
*/
|
||||||
class Coupon extends Model
|
class Coupon extends Model
|
||||||
{
|
{
|
||||||
@ -110,4 +111,16 @@ class Coupon extends Model
|
|||||||
->whereIn("distribution_object",[1,2])
|
->whereIn("distribution_object",[1,2])
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取购买服务包的用户可领取的优惠卷列表
|
||||||
|
* @return Collection|array
|
||||||
|
*/
|
||||||
|
public static function getOrderServicePackageCouponList(): Collection|array
|
||||||
|
{
|
||||||
|
return self::where("coupon_client",1)
|
||||||
|
->where("coupon_status",1)
|
||||||
|
->whereIn("distribution_object",[7])
|
||||||
|
->get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,7 +61,6 @@ class UserCoupon extends Model
|
|||||||
/**
|
/**
|
||||||
* 获取优惠卷信息-多条
|
* 获取优惠卷信息-多条
|
||||||
* @param array $params
|
* @param array $params
|
||||||
* @param array $coupon_params
|
|
||||||
* @param array $fields
|
* @param array $fields
|
||||||
* @return Collection|array
|
* @return Collection|array
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -198,4 +198,29 @@ class CouponService extends BaseService
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发放购买服务包的关联优惠卷
|
||||||
|
* @param string $user_id 用户id
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function GrantBuyOrderServicePackageCoupon(string $user_id): bool
|
||||||
|
{
|
||||||
|
// 获取购买服务包的用户可领取的优惠卷列表
|
||||||
|
$coupon = Coupon::getOrderServicePackageCouponList();
|
||||||
|
if (empty($coupon)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($coupon as $value){
|
||||||
|
// 发放优惠卷
|
||||||
|
$res = $this->GrantUserCoupon($value['coupon_id'],$user_id);
|
||||||
|
if (!$res){
|
||||||
|
// 发放失败
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -533,7 +533,7 @@ class OrderServicePackageService extends BaseService
|
|||||||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 增加健康包订单关联商品
|
// 处理健康包数据
|
||||||
if ($request_params['service_type'] == 1){
|
if ($request_params['service_type'] == 1){
|
||||||
// 获取医生健康包配置
|
// 获取医生健康包配置
|
||||||
$params = array();
|
$params = array();
|
||||||
|
|||||||
@ -32,6 +32,7 @@ use App\Model\OrderProductLogistic;
|
|||||||
use App\Model\OrderServicePackage;
|
use App\Model\OrderServicePackage;
|
||||||
use App\Model\OrderServicePackageCase;
|
use App\Model\OrderServicePackageCase;
|
||||||
use App\Model\OrderServicePackageDetail;
|
use App\Model\OrderServicePackageDetail;
|
||||||
|
use App\Model\OrderServicePackageProduct;
|
||||||
use App\Model\OrderServicePackageRefund;
|
use App\Model\OrderServicePackageRefund;
|
||||||
use App\Model\PatientFamily;
|
use App\Model\PatientFamily;
|
||||||
use App\Model\PatientFamilyHealth;
|
use App\Model\PatientFamilyHealth;
|
||||||
@ -2711,6 +2712,7 @@ class PatientOrderService extends BaseService
|
|||||||
return fail(HttpEnumCode::HTTP_ERROR,"非法订单");
|
return fail(HttpEnumCode::HTTP_ERROR,"非法订单");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取订单详情数据
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['order_service_id'] = $order_service_package['order_service_id'];
|
$params['order_service_id'] = $order_service_package['order_service_id'];
|
||||||
$order_service_package_detail = OrderServicePackageDetail::getOne($params);
|
$order_service_package_detail = OrderServicePackageDetail::getOne($params);
|
||||||
@ -2718,10 +2720,30 @@ class PatientOrderService extends BaseService
|
|||||||
return fail(HttpEnumCode::HTTP_ERROR,"非法订单");
|
return fail(HttpEnumCode::HTTP_ERROR,"非法订单");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 健康报
|
// 定义返回数据
|
||||||
|
$result = array();
|
||||||
|
$result['order_service_package_detail'] = $order_service_package_detail->toArray(); // 订单详情数据
|
||||||
|
$result['order_service_package_product'] = []; // 健康包商品数据
|
||||||
|
$result['order_service_package_coupon'] = []; // 健康包关联优惠卷数据
|
||||||
|
$result['order_inquiry'] = []; // 健康包问诊订单数据
|
||||||
|
$result['order_product'] = []; // 健康包药品订单数据
|
||||||
|
|
||||||
|
|
||||||
|
// 健康包商品数据
|
||||||
if ($order_service_package['order_service_type'] == 1){
|
if ($order_service_package['order_service_type'] == 1){
|
||||||
$params = array();
|
$params = array();
|
||||||
$params['order_service_id'] = $order_service_package['order_service_id'];
|
$params['order_service_id'] = $order_service_package['order_service_id'];
|
||||||
|
$order_service_package_product = OrderServicePackageProduct::getList($params);
|
||||||
|
if (empty($order_service_package_product)){
|
||||||
|
return fail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 健康包关联优惠卷数据
|
||||||
|
if (in_array($order_service_package['order_service_status'],[3,4,5])){
|
||||||
|
// 订单状态(1:待支付 2:未开始 3:服务中 4:服务完成 5:服务取消)
|
||||||
|
// 获取用户优惠卷
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return success($order_service_package_detail->toArray());
|
return success($order_service_package_detail->toArray());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user