新增amqp队列,新增订单创建
This commit is contained in:
parent
67937326ac
commit
0158250f41
37
app/Amqp/Consumer/CancelUnpayOrdersDelayDirectConsumer.php
Normal file
37
app/Amqp/Consumer/CancelUnpayOrdersDelayDirectConsumer.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Amqp\Consumer;
|
||||
|
||||
use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Result;
|
||||
use Hyperf\Amqp\Annotation\Consumer;
|
||||
use Hyperf\Amqp\Message\ConsumerMessage;
|
||||
use PhpAmqpLib\Message\AMQPMessage;
|
||||
use Hyperf\Amqp\Message\Type;
|
||||
|
||||
/**
|
||||
* 取消未支付订单消费者-延迟队列
|
||||
*/
|
||||
#[Consumer(nums: 1)]
|
||||
class CancelUnpayOrdersDelayDirectConsumer extends ConsumerMessage
|
||||
{
|
||||
use ProducerDelayedMessageTrait;
|
||||
use ConsumerDelayedMessageTrait;
|
||||
|
||||
protected string $exchange = 'amqp.delay.direct';
|
||||
|
||||
protected ?string $queue = 'cancel.unpay.orders.delay.queue';
|
||||
|
||||
protected string $type = Type::DIRECT; //Type::FANOUT;
|
||||
|
||||
protected string|array $routingKey = '';
|
||||
|
||||
public function consumeMessage($data, AMQPMessage $message): string
|
||||
{
|
||||
dump($data);
|
||||
return Result::ACK;
|
||||
}
|
||||
}
|
||||
31
app/Amqp/Producer/AmqpDelayDirectProducer.php
Normal file
31
app/Amqp/Producer/AmqpDelayDirectProducer.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Amqp\Producer;
|
||||
|
||||
use Hyperf\Amqp\Annotation\Producer;
|
||||
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\ProducerMessage;
|
||||
use Hyperf\Amqp\Message\Type;
|
||||
|
||||
/**
|
||||
* 延迟队列
|
||||
* 生产者
|
||||
*/
|
||||
#[Producer]
|
||||
class AmqpDelayDirectProducer extends ProducerMessage
|
||||
{
|
||||
use ProducerDelayedMessageTrait;
|
||||
|
||||
protected string $exchange = 'amqp.delay.direct';
|
||||
|
||||
protected string $type = Type::DIRECT;
|
||||
|
||||
protected string|array $routingKey = '';
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->payload = $data;
|
||||
}
|
||||
}
|
||||
@ -2,11 +2,14 @@
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Amqp\Producer\AmqpDelayDirectProducer;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Request\OrderInquiryRequest;
|
||||
use App\Request\UserPatientRequest;
|
||||
use App\Services\OrderInquiryService;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Hyperf\Validation\Contract\ValidatorFactoryInterface;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
@ -25,6 +28,16 @@ class OrderInquiryController extends AbstractController
|
||||
*/
|
||||
public function addInquiryOrder(): ResponseInterface
|
||||
{
|
||||
// $message = new AmqpDelayDirectProducer(10000);
|
||||
// $message->setDelayMs(10000);
|
||||
// $producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
// $producer->produce($message);
|
||||
//
|
||||
// $message = new AmqpDelayDirectProducer(5000);
|
||||
// $message->setDelayMs(5000);
|
||||
// $producer = ApplicationContext::getContainer()->get(Producer::class);
|
||||
// $producer->produce($message);
|
||||
|
||||
$request = $this->container->get(OrderInquiryRequest::class);
|
||||
$request->scene('addInquiryOrder')->validateResolved();
|
||||
|
||||
|
||||
@ -85,4 +85,14 @@ class InquiryCaseProduct extends Model
|
||||
->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param array $data
|
||||
* @return \Hyperf\Database\Model\Model|InquiryCaseProduct
|
||||
*/
|
||||
public static function addInquiryCaseProduct(array $data): \Hyperf\Database\Model\Model|InquiryCaseProduct
|
||||
{
|
||||
return self::create($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ class OrderInquiryCase extends Model
|
||||
*/
|
||||
protected array $casts = ['inquiry_case_id' => 'integer', 'inquiry_cases_id' => 'integer', 'user_id' => 'integer', 'patient_id' => 'integer', 'order_inquiry_id' => 'integer', 'family_id' => 'integer', 'relation' => 'integer', 'status' => 'integer', 'sex' => 'integer', 'age' => 'integer', 'disease_class_id' => 'integer', 'is_allergy_history' => 'integer', 'is_family_history' => 'integer', 'is_pregnant' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
|
||||
|
||||
protected string $primaryKey = "inquiry_cases_id";
|
||||
protected string $primaryKey = "inquiry_case_id";
|
||||
|
||||
/**
|
||||
* 关联问诊订单表
|
||||
|
||||
73
app/Model/OrderInquiryCoupon.php
Normal file
73
app/Model/OrderInquiryCoupon.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Database\Model\Relations\HasOne;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $order_coupon_id 主键id
|
||||
* @property int $order_inquiry_id 订单-问诊id
|
||||
* @property int $user_coupon_id 用户优惠卷表
|
||||
* @property string $coupon_name 优惠卷名称
|
||||
* @property string $coupon_use_price 优惠卷使用金额
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class OrderInquiryCoupon extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'order_inquiry_coupon';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['order_coupon_id', 'order_inquiry_id', 'user_coupon_id', 'coupon_name', 'coupon_use_price', 'created_at', 'updated_at'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*/
|
||||
protected array $casts = ['order_coupon_id' => 'string', 'order_inquiry_id' => 'string', 'user_coupon_id' => 'string', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
|
||||
|
||||
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 OrderInquiryCoupon|\Hyperf\Database\Model\Model
|
||||
*/
|
||||
public static function addOrderInquiryCoupon(array $data): \Hyperf\Database\Model\Model|OrderInquiryCoupon
|
||||
{
|
||||
return self::create($data);
|
||||
}
|
||||
}
|
||||
@ -38,4 +38,28 @@ class ProductPlatformAmount extends Model
|
||||
protected array $casts = ['amount_id' => 'integer', 'product_platform_id' => 'integer', 'real_stock' => 'integer', 'stock' => 'integer', 'lock_stock' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
|
||||
|
||||
protected string $primaryKey = "amount_id";
|
||||
|
||||
/**
|
||||
* 自增
|
||||
* @param array $params
|
||||
* @param string $field
|
||||
* @param float $numeral
|
||||
* @return int
|
||||
*/
|
||||
public static function inc(array $params,string $field,float $numeral = 1): int
|
||||
{
|
||||
return self::where($params)->increment($field,$numeral);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自减
|
||||
* @param array $params
|
||||
* @param string $field
|
||||
* @param float $numeral
|
||||
* @return int
|
||||
*/
|
||||
public static function dec(array $params,string $field,float $numeral = 1): int
|
||||
{
|
||||
return self::where($params)->decrement($field,$numeral);
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ class UserCoupon extends Model
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*/
|
||||
protected array $casts = ['user_coupon_id' => 'integer', 'user_id' => 'integer', 'patient_id' => 'integer', 'coupon_id' => 'integer', 'user_coupon_status' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
|
||||
protected array $casts = ['user_coupon_id' => 'string', 'user_id' => 'string', 'patient_id' => 'string', 'coupon_id' => 'string', 'user_coupon_status' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];
|
||||
|
||||
protected string $primaryKey = "user_coupon_id";
|
||||
|
||||
@ -70,15 +70,32 @@ class UserCoupon extends Model
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getWithCouponList(array $params,array $coupon_params, array $fields = ['*']): Collection|array
|
||||
public static function getWithCouponList(array $params,array $coupon_params,array $application_scope_params, array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::with(['Coupon'])
|
||||
->whereHas('Coupon' , function($query) use ($coupon_params){
|
||||
$query->where($coupon_params);
|
||||
->whereHas('Coupon' , function($query) use ($coupon_params,$application_scope_params){
|
||||
$query->where($coupon_params)->whereIn('application_scope',$application_scope_params);
|
||||
})
|
||||
->where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取优惠卷信息-单条
|
||||
* @param array $params
|
||||
* @param array $coupon_params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getWithCouponOne(array $params,array $coupon_params, array $application_scope_params,array $fields = ['*']): object|null
|
||||
{
|
||||
return self::with(['Coupon'])
|
||||
->whereHas('Coupon' , function($query) use ($coupon_params,$application_scope_params){
|
||||
$query->where($coupon_params)->whereIn('application_scope',$application_scope_params);
|
||||
})
|
||||
->where($params)
|
||||
->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户优惠卷
|
||||
* @param array $data
|
||||
|
||||
@ -117,11 +117,16 @@ class BasicDataService extends BaseService
|
||||
{
|
||||
$manual_id = $this->request->route('manual_id');
|
||||
|
||||
$fields = [
|
||||
'manual_id',
|
||||
'title',
|
||||
];
|
||||
|
||||
$params = array();
|
||||
$params['manual_id'] = $manual_id;
|
||||
$params['status'] = 1;
|
||||
|
||||
$operation_manual = OperationManual::getOne($params);
|
||||
$operation_manual = OperationManual::getOne($params,$fields);
|
||||
if (empty($operation_manual)){
|
||||
return fail();
|
||||
}
|
||||
|
||||
@ -11,13 +11,13 @@ use App\Model\UserCoupon;
|
||||
class CouponService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 获取用户可用优惠卷
|
||||
* 获取用户可用优惠卷-列表
|
||||
* @param string|int $user_id 用户id
|
||||
* @param string|int $inquiry_type 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||
* @param int $coupon_client 使用平台(1:小程序)
|
||||
* @return array
|
||||
*/
|
||||
public function getUserUsableCoupon(string|int $user_id,string|int $inquiry_type,int $coupon_client = 1): array
|
||||
public function getUserUsableCouponList(string|int $user_id, string|int $inquiry_type, int $coupon_client = 1): array
|
||||
{
|
||||
// 问诊类型需加1
|
||||
$inquiry_type = $inquiry_type + 1;
|
||||
@ -31,9 +31,42 @@ class CouponService extends BaseService
|
||||
$coupon_params = array();
|
||||
$coupon_params[] = ['coupon_client','=',$coupon_client];
|
||||
$coupon_params[] = ['coupon_status','=',1]; // 状态(1:正常 2:强制失效 3:结束 4:删除)
|
||||
$coupon_params[] = ['application_scope','in',[1,$inquiry_type]]; // 适用范围(1:全部 2:快速问诊 3:专家问诊 4:公益问诊 5:问诊购药)
|
||||
|
||||
$user_coupon = UserCoupon::getWithCouponList($params,$coupon_params);
|
||||
$application_scope_params = [1,$inquiry_type]; // 适用范围(1:全部 2:快速问诊 3:专家问诊 4:公益问诊 5:问诊购药)
|
||||
|
||||
$user_coupon = UserCoupon::getWithCouponList($params,$coupon_params,$application_scope_params);
|
||||
if (empty($user_coupon)){
|
||||
return array();
|
||||
}
|
||||
|
||||
return $user_coupon->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户可用优惠卷-单条
|
||||
* @param string|int $user_id 用户id
|
||||
* @param string|int $inquiry_type 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||
* @param int $coupon_client 使用平台(1:小程序)
|
||||
* @return array
|
||||
*/
|
||||
public function getUserUsableCouponOne(string|int $user_id, string|int $inquiry_type, int $coupon_client = 1): array
|
||||
{
|
||||
// 问诊类型需加1
|
||||
$inquiry_type = $inquiry_type + 1;
|
||||
|
||||
$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())]; // 过期使用时间
|
||||
|
||||
$coupon_params = array();
|
||||
$coupon_params[] = ['coupon_client','=',$coupon_client];
|
||||
$coupon_params[] = ['coupon_status','=',1]; // 状态(1:正常 2:强制失效 3:结束 4:删除)
|
||||
|
||||
$application_scope_params = [1,$inquiry_type]; // 适用范围(1:全部 2:快速问诊 3:专家问诊 4:公益问诊 5:问诊购药)
|
||||
|
||||
$user_coupon = UserCoupon::getWithCouponOne($params,$coupon_params,$application_scope_params);
|
||||
if (empty($user_coupon)){
|
||||
return array();
|
||||
}
|
||||
|
||||
@ -2,19 +2,26 @@
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Amqp\Producer\AmqpDelayDirectProducer;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\DiseaseClass;
|
||||
use App\Model\DoctorInquiryConfig;
|
||||
use App\Model\InquiryCaseProduct;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderInquiryCase;
|
||||
use App\Model\OrderInquiryCoupon;
|
||||
use App\Model\PatientFamily;
|
||||
use App\Model\Product;
|
||||
use App\Model\ProductPlatformAmount;
|
||||
use App\Model\SystemInquiryConfig;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Utils\PcreMatch;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Hyperf\Snowflake\IdGeneratorInterface;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
/**
|
||||
* 问诊订单
|
||||
@ -34,9 +41,9 @@ class OrderInquiryService extends BaseService
|
||||
$params['inquiry_refund_status'] = 0; // 无退款
|
||||
|
||||
$order_inquiry_count = OrderInquiry::getCount($params);
|
||||
if (!empty($order_inquiry_count) || $order_inquiry_count != 0){
|
||||
if (!empty($order_inquiry_count) || $order_inquiry_count != 0) {
|
||||
$not_accepted_inquiry_num = $order_inquiry_count;
|
||||
}else{
|
||||
} else {
|
||||
$not_accepted_inquiry_num = $order_inquiry_count;
|
||||
}
|
||||
|
||||
@ -56,9 +63,9 @@ class OrderInquiryService extends BaseService
|
||||
$params['inquiry_refund_status'] = 0; // 无退款
|
||||
|
||||
$order_inquiry_count = OrderInquiry::getCount($params);
|
||||
if (!empty($order_inquiry_count) || $order_inquiry_count != 0){
|
||||
if (!empty($order_inquiry_count) || $order_inquiry_count != 0) {
|
||||
$accepting_inquiry_num = $order_inquiry_count;
|
||||
}else{
|
||||
} else {
|
||||
$accepting_inquiry_num = $order_inquiry_count;
|
||||
}
|
||||
|
||||
@ -72,13 +79,13 @@ class OrderInquiryService extends BaseService
|
||||
* @param string $date
|
||||
* @return float
|
||||
*/
|
||||
public function getDoctorDayAmountTotal(string $doctor_id,string $date): float
|
||||
public function getDoctorDayAmountTotal(string $doctor_id, string $date): float
|
||||
{
|
||||
// 获取当天开始时间
|
||||
$start_date = date('Y-m-d 00:00:00',strtotime($date));
|
||||
$start_date = date('Y-m-d 00:00:00', strtotime($date));
|
||||
|
||||
// 获取当天结束时间
|
||||
$end_date = date('Y-m-d 23:59:59',strtotime($date));
|
||||
$end_date = date('Y-m-d 23:59:59', strtotime($date));
|
||||
|
||||
// 获取医生当日接诊订单金额
|
||||
$params = array();
|
||||
@ -87,17 +94,23 @@ class OrderInquiryService extends BaseService
|
||||
$params['inquiry_pay_status'] = 2; // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
$params['settlement_status'] = 0; // 订单与医生结算状态(0:未结算 1:已结算)
|
||||
|
||||
$reception_time = [$start_date,$end_date];
|
||||
$reception_time = [$start_date, $end_date];
|
||||
|
||||
$inquiry_status_params = [4,5]; // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
$inquiry_status_params = [4, 5]; // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消)
|
||||
|
||||
$amount_total_sum = OrderInquiry::getOrderInquiryAmountTotalSum($params,$reception_time,$inquiry_status_params);
|
||||
$amount_total_sum = OrderInquiry::getOrderInquiryAmountTotalSum($params, $reception_time, $inquiry_status_params);
|
||||
|
||||
return $amount_total_sum ?: 0;
|
||||
}
|
||||
|
||||
// 创建问诊订单
|
||||
public function addInquiryOrder(){
|
||||
/**
|
||||
* 创建问诊订单
|
||||
* @return array
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function addInquiryOrder(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
$request_params = $this->request->all();
|
||||
|
||||
@ -107,51 +120,20 @@ class OrderInquiryService extends BaseService
|
||||
$params['patient_id'] = $user_info['client_user_id'];
|
||||
$params['status'] = 1;
|
||||
$patient_family = PatientFamily::getOne($params);
|
||||
if (empty($patient_family)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"患者信息错误");
|
||||
if (empty($patient_family)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "患者信息错误");
|
||||
}
|
||||
|
||||
// 检测当前家庭成员是否存在未完成的问诊订单
|
||||
$UserPatientService = new UserPatientService();
|
||||
$res = $UserPatientService->getNotFinishedOrdeInquiry($user_info['client_user_id']);
|
||||
if (!empty($res)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"当前患者存在进行中的问诊订单");
|
||||
}
|
||||
|
||||
// 问诊购药情况
|
||||
if ($request_params['inquiry_type'] == 4){
|
||||
// 问诊购药情况下是否包含用药意向
|
||||
if (!empty($request_params['product'])){
|
||||
foreach ($request_params['product'] as $item){
|
||||
$params = array();
|
||||
$params['product_id'] = $item['product_id'];
|
||||
$product = Product::getWithAmountOne($params);
|
||||
if (empty($product)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"意向药品错误");
|
||||
}
|
||||
|
||||
// 检测商品库存
|
||||
if (!empty($product['ProductPlatformAmount'])){
|
||||
if ($item['product_num'] > $product['ProductPlatformAmount']['real_stock']){
|
||||
// 此处是否需要特殊返回
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"意向药品库存不足");
|
||||
}
|
||||
}
|
||||
|
||||
// 用药意向是否和过敏史重叠
|
||||
if (!empty($request_params['allergy_history'])){
|
||||
$res = strpos($request_params['allergy_history'],$product['product_name']);
|
||||
if ($res !== false){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"过敏史中存在意向用药,请您仔细检查");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($res)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "当前患者存在进行中的问诊订单");
|
||||
}
|
||||
|
||||
// 是否为孕妇
|
||||
if (!empty($request_params['is_pregnant'])){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"请您到线下问诊");
|
||||
if (!empty($request_params['is_pregnant'])) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "请您到线下问诊");
|
||||
}
|
||||
|
||||
// 检测所患疾病是否正确
|
||||
@ -159,46 +141,50 @@ class OrderInquiryService extends BaseService
|
||||
$params['disease_class_id'] = $request_params['disease_class_id'];
|
||||
$params['disease_class_status'] = 1;
|
||||
$disease_class = DiseaseClass::getOne($params);
|
||||
if (empty($disease_class)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"疾病信息填写错误");
|
||||
if (empty($disease_class)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "疾病信息填写错误");
|
||||
}
|
||||
|
||||
// 获取当前问诊医生信息
|
||||
// 专家问诊-公益问诊
|
||||
if ($request_params['inquiry_type'] == 3 || $request_params['inquiry_type'] == 1){
|
||||
if (empty($request_params['doctor_id'])){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"未选择医生");
|
||||
if ($request_params['inquiry_type'] == 3 || $request_params['inquiry_type'] == 1) {
|
||||
if (empty($request_params['doctor_id'])) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未选择医生");
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['doctor_id'] = $request_params['doctor_id'];
|
||||
$doctor = UserDoctor::getOne($params);
|
||||
if (empty($doctor)){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"未知医生");
|
||||
if (empty($doctor)) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "未知医生");
|
||||
}
|
||||
|
||||
if ($doctor['idcard_status'] != 1){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"当前医生无法接诊,请重新选择");
|
||||
if ($doctor['idcard_status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "当前医生无法接诊,请重新选择");
|
||||
}
|
||||
|
||||
if ($doctor['iden_auth_status'] != 1){
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"当前医生无法接诊,请重新选择");
|
||||
if ($doctor['iden_auth_status'] != 1) {
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "当前医生无法接诊,请重新选择");
|
||||
}
|
||||
}
|
||||
|
||||
// 获取问诊价格
|
||||
$DoctorInquiryService = new DoctorInquiryService();
|
||||
$inquiry_price = $DoctorInquiryService->getDoctorInquiryPrice($request_params['inquiry_type'],$request_params['inquiry_mode'],$request_params['doctor_id'] ?? "");
|
||||
$inquiry_price = $DoctorInquiryService->getDoctorInquiryPrice($request_params['inquiry_type'], $request_params['inquiry_mode'], $request_params['doctor_id'] ?? "");
|
||||
|
||||
// 获取可用优惠卷
|
||||
$CouponService = new CouponService();
|
||||
$user_coupon = $CouponService->getUserUsableCoupon($user_info['user_id'],$request_params['inquiry_type'],1);
|
||||
$user_coupon = $CouponService->getUserUsableCouponOne($user_info['user_id'], $request_params['inquiry_type']);
|
||||
|
||||
Db::beginTransaction();
|
||||
|
||||
$generator = $this->container->get(IdGeneratorInterface::class);
|
||||
|
||||
try {
|
||||
// 实际付款金额
|
||||
$coupon_price = $user_coupon['coupon']['coupon_price'] ?? 0;
|
||||
$payment_amount_total = $inquiry_price - $coupon_price;
|
||||
|
||||
// 生成问诊订单
|
||||
$data = array();
|
||||
$data['user_id'] = $user_info['user_id'];
|
||||
@ -209,18 +195,20 @@ class OrderInquiryService extends BaseService
|
||||
$data['inquiry_mode'] = $request_params['inquiry_mode'];
|
||||
$data['inquiry_status'] = 1;// 1:待支付
|
||||
$data['inquiry_no'] = $generator->generate();// 订单编号
|
||||
$data['amount_total'] = $inquiry_price ?? 0;// 订单金额
|
||||
$data['amount_total'] = $inquiry_price;// 订单金额
|
||||
$data['payment_amount_total'] = $payment_amount_total;// 实际付款金额
|
||||
$data['patient_name'] = $patient_family['card_name'];// 患者姓名-就诊人
|
||||
$data['patient_name_mask'] = $patient_family['card_name_mask'];// 患者姓名-就诊人(掩码)
|
||||
$data['patient_sex'] = $patient_family['sex'];// 患者性别-就诊人(0:未知 1:男 2:女)
|
||||
$data['patient_age'] = $patient_family['age'];// 患者年龄-就诊人
|
||||
$order_inquiry = OrderInquiry::addOrderInquiry($data);
|
||||
if (empty($order_inquiry)){
|
||||
return fail(HttpEnumCode::SERVER_ERROR,"订单创建失败");
|
||||
if (empty($order_inquiry)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||||
}
|
||||
|
||||
// 处理复诊凭证
|
||||
if (!empty($request_params['diagnose_images'])){
|
||||
if (!empty($request_params['diagnose_images'])) {
|
||||
// 医师资格证
|
||||
$diagnose_images = implode(',', $request_params['diagnose_images']);
|
||||
$diagnose_images = PcreMatch::pregRemoveOssWebsite($diagnose_images);
|
||||
@ -249,23 +237,102 @@ class OrderInquiryService extends BaseService
|
||||
$data['family_history'] = $request_params['family_history'] ?? null; // 家族病史描述
|
||||
$data['is_pregnant'] = $request_params['is_pregnant'] ?: 0; // 是否备孕、妊娠、哺乳期(0:否 1:是)
|
||||
$order_inquiry_case = OrderInquiryCase::addOrderInquiryCase($data);
|
||||
if (empty($order_inquiry_case)){
|
||||
return fail(HttpEnumCode::SERVER_ERROR,"订单创建失败");
|
||||
if (empty($order_inquiry_case)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||||
}
|
||||
|
||||
// 增加意向用药表
|
||||
// 增加问诊优惠卷表
|
||||
if (!empty($user_coupon)){
|
||||
$data = array();
|
||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];// 订单-问诊id
|
||||
$data['user_coupon_id'] = $user_coupon['user_coupon_id'];
|
||||
$data['coupon_name'] = $user_coupon['coupon']['coupon_name'];
|
||||
$data['coupon_use_price'] = $user_coupon['coupon']['coupon_price'];
|
||||
$order_inquiry_coupon = OrderInquiryCoupon::addOrderInquiryCoupon($data);
|
||||
if (empty($order_inquiry_coupon)){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||||
}
|
||||
}
|
||||
|
||||
// 锁定库存
|
||||
// 意向用药处理
|
||||
if ($request_params['inquiry_type'] == 4 && !empty($request_params['product'])) {
|
||||
foreach ($request_params['product'] as $item) {
|
||||
$params = array();
|
||||
$params['product_id'] = $item['product_id'];
|
||||
$product = Product::getWithAmountOne($params);
|
||||
if (empty($product)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "意向药品错误");
|
||||
}
|
||||
|
||||
// 检测商品库存
|
||||
// if (!empty($product['ProductPlatformAmount'])) {
|
||||
// if ($item['product_num'] > $product['ProductPlatformAmount']['real_stock']) {
|
||||
// // 此处是否需要特殊返回
|
||||
// Db::rollBack();
|
||||
// return fail(HttpEnumCode::HTTP_ERROR, "意向药品库存不足");
|
||||
// }
|
||||
// }
|
||||
|
||||
// 用药意向是否和过敏史重叠
|
||||
if (!empty($request_params['allergy_history'])) {
|
||||
$res = strpos($request_params['allergy_history'], $product['product_name']);
|
||||
if ($res !== false) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, "过敏史中存在意向用药,请您仔细检查");
|
||||
}
|
||||
}
|
||||
|
||||
// 新增病例商品表
|
||||
$data = array();
|
||||
$data['inquiry_case_id'] = $order_inquiry_case['inquiry_case_id'];
|
||||
$data['product_id'] = $item['product_id'];
|
||||
$data['case_product_num'] = $item['product_num'];
|
||||
$inquiry_case_product = InquiryCaseProduct::addInquiryCaseProduct($data);
|
||||
if (empty($inquiry_case_product)) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||||
}
|
||||
|
||||
// 锁定库存
|
||||
// 实际库存-1
|
||||
// $params = array();
|
||||
// $params['amount_id'] = $product['ProductPlatformAmount']['amount_id'];
|
||||
// ProductPlatformAmount::dec($params,'real_stock',$item['product_num']);
|
||||
//
|
||||
// // 锁定库存+1
|
||||
// ProductPlatformAmount::inc($params,'lock_stock',$item['product_num']);
|
||||
}
|
||||
}
|
||||
|
||||
// 增加至退款延迟队列
|
||||
$data = array();
|
||||
$data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
|
||||
$message = new AmqpDelayDirectProducer($data);
|
||||
$message->setDelayMs(60 * 30 * 1000);
|
||||
$producer = $this->container->get(Producer::class) ;
|
||||
$res = $producer->produce($message);
|
||||
if(!$res){
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
|
||||
}
|
||||
|
||||
$result = array();
|
||||
$result['amount_total'] = $inquiry_price; // 订单金额
|
||||
$result['inquiry_no'] = $order_inquiry['inquiry_no']; // 订单编号
|
||||
$result['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; // 订单主键id
|
||||
$result['created_at'] = date('Y-m-d H:i:s',strtotime($order_inquiry['created_at'])); // 创建时间
|
||||
$result['inquiry_type'] = $order_inquiry['inquiry_type']; // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药)
|
||||
|
||||
|
||||
return success($result);
|
||||
}
|
||||
}
|
||||
@ -32,7 +32,7 @@ class UserPatientService extends BaseService
|
||||
$order_inquiry = OrderInquiry::getOne($params);
|
||||
if (!empty($order_inquiry)) {
|
||||
// 1:待支付 2:待分配 3:待接诊 4:已接诊
|
||||
if (in_array($order_inquiry['inquiry_status'], [1, 2, 3, 4])) {
|
||||
if (in_array($order_inquiry['inquiry_status'], [2, 3, 4])) {
|
||||
return $order_inquiry['order_inquiry_id'];
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
"alibabacloud/dysmsapi-20170525": "2.0.23",
|
||||
"aliyuncs/oss-sdk-php": "^2.6",
|
||||
"firebase/php-jwt": "^6.3",
|
||||
"hyperf/amqp": "~3.0.0",
|
||||
"hyperf/amqp": "^3.0",
|
||||
"hyperf/async-queue": "~3.0.0",
|
||||
"hyperf/cache": "~3.0.0",
|
||||
"hyperf/command": "~3.0.0",
|
||||
|
||||
14
composer.lock
generated
14
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "92f639e766460b0a3fdd041d550e5010",
|
||||
"content-hash": "9859f63a183816d1cef351a84d674792",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adbario/php-dot-notation",
|
||||
@ -1305,16 +1305,16 @@
|
||||
},
|
||||
{
|
||||
"name": "hyperf/amqp",
|
||||
"version": "v3.0.0",
|
||||
"version": "v3.0.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/hyperf/amqp.git",
|
||||
"reference": "20d4d9265003437557d567e02bd3b07ca1c40dbc"
|
||||
"reference": "87b2a2081be8e58c6dad377360f033361a2742ea"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://mirrors.huaweicloud.com/repository/php/hyperf/amqp/v3.0.0/hyperf-amqp-v3.0.0.zip",
|
||||
"reference": "20d4d9265003437557d567e02bd3b07ca1c40dbc",
|
||||
"url": "https://mirrors.huaweicloud.com/repository/php/hyperf/amqp/v3.0.3/hyperf-amqp-v3.0.3.zip",
|
||||
"reference": "87b2a2081be8e58c6dad377360f033361a2742ea",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1324,7 +1324,7 @@
|
||||
"hyperf/process": "~3.0.0",
|
||||
"hyperf/utils": "~3.0.0",
|
||||
"php": ">=8.0",
|
||||
"php-amqplib/php-amqplib": "^3.1",
|
||||
"php-amqplib/php-amqplib": "3.4.0",
|
||||
"psr/container": "^1.0|^2.0",
|
||||
"psr/event-dispatcher": "^1.0",
|
||||
"psr/log": "^1.0|^2.0|^3.0"
|
||||
@ -1357,7 +1357,7 @@
|
||||
"hyperf",
|
||||
"php"
|
||||
],
|
||||
"time": "2022-12-10T13:24:37+00:00"
|
||||
"time": "2023-01-17T09:54:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "hyperf/async-queue",
|
||||
|
||||
@ -11,11 +11,11 @@ declare(strict_types=1);
|
||||
*/
|
||||
return [
|
||||
'default' => [
|
||||
'host' => env('AMQP_HOST', 'localhost'),
|
||||
'host' => env('AMQP_HOST', '42.193.16.243'),
|
||||
'port' => (int) env('AMQP_PORT', 5672),
|
||||
'user' => env('AMQP_USER', 'guest'),
|
||||
'password' => env('AMQP_PASSWORD', 'guest'),
|
||||
'vhost' => env('AMQP_VHOST', '/'),
|
||||
'user' => env('AMQP_USER', 'gdxz_2022rabbitmq'),
|
||||
'password' => env('AMQP_PASSWORD', 'qwr2p&¥e@3.2p'),
|
||||
'vhost' => env('AMQP_VHOST', 'gdxz_2022rabbitmq'),
|
||||
'concurrent' => [
|
||||
'limit' => 1,
|
||||
],
|
||||
@ -27,8 +27,8 @@ return [
|
||||
'login_method' => 'AMQPLAIN',
|
||||
'login_response' => null,
|
||||
'locale' => 'en_US',
|
||||
'connection_timeout' => 3,
|
||||
'read_write_timeout' => 6,
|
||||
'connection_timeout' => 10,
|
||||
'read_write_timeout' => 10,
|
||||
'context' => null,
|
||||
'keepalive' => true,
|
||||
'heartbeat' => 3,
|
||||
|
||||
@ -33,13 +33,22 @@ return [
|
||||
'algo' => env('JWT_ALGO', 'HS256'),
|
||||
],
|
||||
"we_chat" => [ // 微信配置
|
||||
"doctor" => [
|
||||
"app_id" => env('DOCTOR_WECHAT_APP_ID', 'wxc83296720404aa7b'),
|
||||
"secret" => env('DOCTOR_WECHAT_APP_SECRET', '817665d3763637fe66d56548f8484622'),
|
||||
"applets" =>[ // 小程序
|
||||
"doctor" => [
|
||||
"app_id" => env('DOCTOR_WECHAT_APP_ID', 'wxc83296720404aa7b'),
|
||||
"secret" => env('DOCTOR_WECHAT_APP_SECRET', '817665d3763637fe66d56548f8484622'),
|
||||
],
|
||||
"patient" => [
|
||||
"app_id" => env('PATIENT_WECHAT_APP_ID', 'wx70a196902e0841b6'),
|
||||
"secret" => env('PATIENT_WECHAT_APP_SECRET', '2671d2f4285180ddec5a5a2b16ed50f2'),
|
||||
]
|
||||
],
|
||||
"patient" => [
|
||||
"app_id" => env('PATIENT_WECHAT_APP_ID', 'wx70a196902e0841b6'),
|
||||
"secret" => env('PATIENT_WECHAT_APP_SECRET', '2671d2f4285180ddec5a5a2b16ed50f2'),
|
||||
"pay" => [
|
||||
"patient" => [
|
||||
"app_id" => env('PATIENT_WECHAT_APP_ID', 'wx70a196902e0841b6'),
|
||||
"mchid" => env('PATIENT_WECHAT_MCH_ID', '1636644248'),
|
||||
"secret" => env('PATIENT_WECHAT_APP_SECRET', '817665d3763637fe66d56548f8484622'),
|
||||
],
|
||||
]
|
||||
],
|
||||
"alibaba" => [// 阿里
|
||||
|
||||
@ -34,11 +34,11 @@ class Wechat
|
||||
public function __construct(string $user_type)
|
||||
{
|
||||
if ($user_type == 1){
|
||||
$this->config = config("we_chat.patient");
|
||||
$this->config = config("we_chat.applets.patient");
|
||||
}elseif ($user_type == 2){
|
||||
$this->config = config("we_chat.doctor");
|
||||
$this->config = config("we_chat.applets.doctor");
|
||||
}elseif ($user_type == 3){
|
||||
$this->config = config("we_chat.pharmacist");
|
||||
$this->config = config("we_chat.applets.pharmacist");
|
||||
}
|
||||
|
||||
if (empty($this->config)){
|
||||
|
||||
@ -29,6 +29,23 @@ REDIS_DB=0
|
||||
JWT_SECRET=X8p44RvrFDlnrvHLN2juwK1sSAlFtfvdZJLLKt97DLf50W7TPOzCKDUZdVkW+PZzWIqPT8fyoXGBAcBK2faHiA==
|
||||
JWT_TTL=604800
|
||||
JWT_ALGO=HS256
|
||||
|
||||
# [PATIENT]
|
||||
# [WECHAT]
|
||||
PATIENT_WECHAT_APP_ID=wx70a196902e0841b6
|
||||
PATIENT_WECHAT_APP_SECRET=2671d2f4285180ddec5a5a2b16ed50f2
|
||||
|
||||
# [DOCTOR]
|
||||
# [WECHAT]
|
||||
DOCTOR_WECHAT_APP_ID=wxc83296720404aa7b
|
||||
DOCTOR_WECHAT_APP_SECRET=817665d3763637fe66d56548f8484622
|
||||
|
||||
# [AMQP]
|
||||
AMQP_HOST=42.193.16.243
|
||||
AMQP_PORT=5672
|
||||
AMQP_USER=gdxz_2022rabbitmq
|
||||
AMQP_PASSWORD=qwr2p&¥e@3.2p
|
||||
AMQP_VHOST=gdxz_2022rabbitmq
|
||||
">.env
|
||||
|
||||
#nginx_upstrame="/Users/wucongxing/Desktop/test/hospital-upstream.conf"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user