修改支付中心数据,增加优惠卷不可使用原因
This commit is contained in:
@@ -26,6 +26,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property int $is_delete 删除状态(0:否 1:是)
|
||||
* @property int $cancel_reason 订单取消原因(1:主动取消 2:复核失败/库存不足 3:支付超时 4:客服取消)
|
||||
* @property string $amount_total 订单金额
|
||||
* @property string $coupon_amount_total 优惠卷总金额
|
||||
* @property string $payment_amount_total 实际付款金额
|
||||
* @property string $logistics_fee 运费金额
|
||||
* @property string $logistics_no 物流编号
|
||||
@@ -37,7 +38,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property int $refund_status 商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||
* @property string $cancel_time 订单取消时间
|
||||
* @property string $cancel_remarks 订单取消备注(自动添加)
|
||||
* @property int $report_pre_status 上报处方平台状态(0:未上报 1:已上报 2:上报失败))
|
||||
* @property int $report_pre_status 上报处方平台状态(0:未上报 1:已上报 2:上报失败 3:上报取消)
|
||||
* @property string $report_pre_time 上报处方平台时间
|
||||
* @property string $report_pre_fail_reason 上报失败原因
|
||||
* @property int $province_id 省份id
|
||||
@@ -54,10 +55,10 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property string $consignee_tel_mask 收货人电话(掩码)
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
* @property-read OrderPrescription $OrderPrescription
|
||||
* @property-read \Hyperf\Database\Model\Collection|OrderPrescriptionIcd[] $OrderPrescriptionIcd
|
||||
* @property-read \Hyperf\Database\Model\Collection|OrderProductItem[] $OrderProductItem
|
||||
* @property-read PatientFamily $PatientFamily
|
||||
* @property-read OrderPrescription|null $OrderPrescription
|
||||
* @property-read \Hyperf\Database\Model\Collection|OrderPrescriptionIcd[]|null $OrderPrescriptionIcd
|
||||
* @property-read \Hyperf\Database\Model\Collection|OrderProductItem[]|null $OrderProductItem
|
||||
* @property-read PatientFamily|null $PatientFamily
|
||||
*/
|
||||
class OrderProduct extends Model
|
||||
{
|
||||
@@ -71,7 +72,7 @@ class OrderProduct extends Model
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['order_product_id', 'order_inquiry_id', 'order_prescription_id', 'doctor_id', 'patient_id', 'family_id', 'order_product_no', 'escrow_trade_no', 'order_product_status', 'pay_channel', 'pay_status', 'is_delete', 'cancel_reason', 'amount_total', 'payment_amount_total', 'logistics_fee', 'logistics_no', 'logistics_company_code', 'sub_logistics_status', 'delivery_time', 'pay_time', 'remarks', 'refund_status', 'cancel_time', 'cancel_remarks', 'report_pre_status', 'report_pre_time', 'report_pre_fail_reason', 'province_id', 'province', 'city_id', 'city', 'county_id', 'county', 'address', 'address_mask', 'consignee_name', 'consignee_name_mask', 'consignee_tel', 'consignee_tel_mask', 'created_at', 'updated_at'];
|
||||
protected array $fillable = ['order_product_id', 'order_inquiry_id', 'order_prescription_id', 'doctor_id', 'patient_id', 'family_id', 'order_product_no', 'escrow_trade_no', 'order_product_status', 'pay_channel', 'pay_status', 'is_delete', 'cancel_reason', 'amount_total', 'coupon_amount_total', 'payment_amount_total', 'logistics_fee', 'logistics_no', 'logistics_company_code', 'sub_logistics_status', 'delivery_time', 'pay_time', 'remarks', 'refund_status', 'cancel_time', 'cancel_remarks', 'report_pre_status', 'report_pre_time', 'report_pre_fail_reason', 'province_id', 'province', 'city_id', 'city', 'county_id', 'county', 'address', 'address_mask', 'consignee_name', 'consignee_name_mask', 'consignee_tel', 'consignee_tel_mask', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "order_product_id";
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $order_coupon_id 主键id
|
||||
* @property int $order_product_id 订单-商品id
|
||||
* @property int $user_coupon_id 用户优惠卷表id
|
||||
* @property string $coupon_name 优惠卷名称
|
||||
* @property string $coupon_use_price 优惠卷使用金额
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class OrderProductCoupon extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'order_product_coupon';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['order_coupon_id', 'order_product_id', 'user_coupon_id', 'coupon_name', 'coupon_use_price', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "order_coupon_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取信息-多条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getList(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return OrderProductCoupon|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addOrderProductCoupon(array $data): \Hyperf\Database\Model\Model|OrderProductCoupon
|
||||
{
|
||||
return self::create($data);
|
||||
}
|
||||
}
|
||||
@@ -122,4 +122,34 @@ class UserCoupon extends Model
|
||||
->where($params)
|
||||
->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者购药可用的优惠卷
|
||||
* @param string|int $user_id 用户id
|
||||
* @param array $coupon_product_datas
|
||||
* @param array $fields 字段
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getUserProductUsableCoupon(string|int $user_id,array $coupon_product_datas,array $fields = ['*']): Collection|array
|
||||
{
|
||||
$params = array();
|
||||
$params[] = ['user_id', '=', $user_id];
|
||||
$params[] = ['user_coupon_status', '=', 0];// 状态(0:未使用 1:已使用 3:已过期)
|
||||
$params[] = ['valid_start_time', '<', date('Y-m-d H:i:s', time())]; // 有效使用时间
|
||||
$params[] = ['valid_end_time', '>', date('Y-m-d H:i:s', time())]; // 过期使用时间
|
||||
|
||||
return self::with(['Coupon'=> function($query) use($coupon_product_datas){
|
||||
$query->where("coupon_client",1)
|
||||
->where("coupon_status",1)
|
||||
->where("application_scope",2)
|
||||
->whereIn("application_scope",[1,3,4,5])
|
||||
->where(function ($query) use ($coupon_product_datas) {
|
||||
foreach ($coupon_product_datas as $coupon_product_data){
|
||||
$query->orwhere("product_id","like",'%' . $coupon_product_data['product_id'] . '%');
|
||||
}
|
||||
});
|
||||
}])
|
||||
->where($params)
|
||||
->get($fields);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user