Compare commits

..

No commits in common. "ad9e345eb357cd7bf0dd3f18f35820623f5416f3" and "8afd0d91ed8829b920219cf676745156c219f421" have entirely different histories.

10 changed files with 2489 additions and 671 deletions

View File

@ -327,7 +327,7 @@ class TestController extends AbstractController
// }
// dump(111);
// 测试药师
// // 测试药师
// $data = array();
// $data['user_id'] = "534534546";
// $data['mobile'] = "18812345678";
@ -351,27 +351,25 @@ class TestController extends AbstractController
// }
// 测试医院
// $data = array();
// $data['user_id'] = "5345345461";
// $data['mobile'] = "18221234167";
// $data['card_name'] = "吴从兴";
// $data['card_num'] = "372929199610075412";
// $data['org_name'] = "成都金牛欣欣相照互联网医院有限公司";
// $data['org_number'] = "91510106MABTJY4K9R";
//
// $result = $CaOnline->getCloudCert($data,'Organizational');
//
// $data = array();
// $data['is_system'] = 1;
// $data['type'] = 2;
// $data['cert_base64'] = $result['certBase64'];
// $data['cert_chain_p7'] = $result['certP7'];
// $data['cert_serial_number'] = $result['certSerialnumber'];
// $data['ca_pin'] = "5345345461";
// $doctor_pharmacist_cert = UserCaCert::addUserCaCert($data);
// if (empty($doctor_pharmacist_cert)){
// return fail();
// }
$data = array();
$data['user_id'] = "5345345461";
$data['mobile'] = "18221234167";
$data['org_name'] = "成都金牛欣欣相照互联网医院有限公司";
$data['org_number'] = "91510106MABTJY4K9R";
$result = $CaOnline->getCloudCert($data,'Organizational');
$data = array();
$data['is_system'] = 1;
$data['type'] = 2;
$data['cert_base64'] = $result['certBase64'];
$data['cert_chain_p7'] = $result['certP7'];
$data['cert_serial_number'] = $result['certSerialnumber'];
$data['ca_pin'] = "5345345461";
$doctor_pharmacist_cert = UserCaCert::addUserCaCert($data);
if (empty($doctor_pharmacist_cert)){
return fail();
}
return 111;
}

View File

@ -11,7 +11,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
/**
* @property int $message_id 主键id
* @property string $from_user_id 发送方user_id
* @property int $from_user_id 发送方user_id
* @property int $to_user_id 接收方user_id
* @property string $message_key 消息唯一标识(系统返回,撤回消息使用)
* @property string $message_send_time 消息发送时间戳

View File

@ -50,7 +50,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
* @property int $patient_age 患者年龄-就诊人
* @property Carbon $created_at 创建时间
* @property Carbon $updated_at 修改时间
* @property-read UserDoctor|null $UserDoctor
* @property-read UserDoctor|null $UserDoctor
* @property-read OrderInquiryCase|null $OrderInquiryCase
*/
class OrderInquiry extends Model

View File

@ -6,8 +6,6 @@ namespace App\Model;
use Carbon\Carbon;
use Hyperf\Database\Model\Relations\HasOne;
use Hyperf\Snowflake\Concern\Snowflake;
/**
@ -16,8 +14,8 @@ use Hyperf\Snowflake\Concern\Snowflake;
* @property int $user_coupon_id 用户优惠卷表id
* @property string $coupon_name 优惠卷名称
* @property string $coupon_use_price 优惠卷使用金额
* @property Carbon $created_at 创建时间
* @property Carbon $updated_at 修改时间
* @property \Carbon\Carbon $created_at 创建时间
* @property \Carbon\Carbon $updated_at 修改时间
*/
class OrderProductCoupon extends Model
{
@ -35,14 +33,6 @@ class OrderProductCoupon extends Model
protected string $primaryKey = "order_coupon_id";
/**
* 关联优惠券表
*/
public function UserCoupon(): HasOne
{
return $this->hasOne(Coupon::class, 'user_coupon_id', 'user_coupon_id');
}
/**
* 获取信息-单条
* @param array $params

View File

@ -41,7 +41,7 @@ class UserCoupon extends Model
protected string $primaryKey = "user_coupon_id";
/**
* 关联优惠券
* 关联医院
*/
public function Coupon(): HasOne
{

View File

@ -4,11 +4,9 @@ namespace App\Services;
use App\Constants\HttpEnumCode;
use App\Exception\BusinessException;
use App\Model\Coupon;
use App\Model\OrderInquiry;
use App\Model\OrderPrescriptionFile;
use App\Model\OrderProduct;
use App\Model\OrderProductCoupon;
use App\Model\PatientFamily;
use App\Model\Product;
use App\Model\UserCaCert;
@ -19,7 +17,6 @@ use App\Model\OrderPrescriptionIcd;
use App\Model\OrderPrescriptionProduct;
use App\Model\OrderProductItem;
use App\Model\User;
use App\Model\UserCoupon;
use App\Model\UserDoctor;
use App\Model\UserDoctorInfo;
use App\Model\UserPharmacist;
@ -31,12 +28,11 @@ use Extend\Ca\CaOffline;
use Extend\Ca\CaOnline;
use Extend\Prescription\Prescription;
use Hyperf\Contract\LengthAwarePaginatorInterface;
use \Hyperf\Coroutine\WaitGroup;
use Hyperf\Utils\WaitGroup;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Swoole\Coroutine\Channel;
use TCPDF;
use Hyperf\Coroutine;
class OrderPrescriptionService extends BaseService
{
@ -218,7 +214,7 @@ class OrderPrescriptionService extends BaseService
}
$wg = new WaitGroup();
$wg->add(9);
$wg->add(8);
$user = []; // 就诊患者用户数据
$patient_family = []; // 家庭成员-基本信息
@ -228,17 +224,15 @@ class OrderPrescriptionService extends BaseService
$user_pharmacist = []; // 药师数据
$user_pharmacist_info = []; // 药师详数据
$order_inquiry_case = []; // 病例数据
$product_coupons = []; // 药品优惠券数据
$user_id = $order_inquiry['user_id'];
$doctor_id = $order_prescription['doctor_id'];
$family_id = $order_inquiry['family_id'];
$pharmacist_id = $order_prescription['pharmacist_id'];
$order_inquiry_id = $order_inquiry['order_inquiry_id'];
$order_product_id = $order_product['order_product_id'];
// 获取就诊患者用户数据
Coroutine\co(function () use ($wg, &$user, $user_id) {
co(function () use ($wg, &$user, $user_id) {
$params = array();
$params['user_id'] = $user_id;
$user = User::getOne($params)->toArray();
@ -247,7 +241,7 @@ class OrderPrescriptionService extends BaseService
});
// 获取家庭成员-基本信息
Coroutine\co(function () use ($wg, &$patient_family, $family_id) {
co(function () use ($wg, &$patient_family, $family_id) {
$params = array();
$params['family_id'] = $family_id;
$patient_family = PatientFamily::getOne($params);
@ -258,7 +252,7 @@ class OrderPrescriptionService extends BaseService
// 获取处方关联疾病数据
$order_prescription_id = $order_prescription['order_prescription_id'];
Coroutine\co(function () use ($wg, &$order_prescription_icd, $order_prescription_id) {
co(function () use ($wg, &$order_prescription_icd, $order_prescription_id) {
$params = array();
$params['order_prescription_id'] = $order_prescription_id;
$order_prescription_icd = OrderPrescriptionIcd::getList($params);
@ -268,7 +262,7 @@ class OrderPrescriptionService extends BaseService
});
// 获取医生数据
Coroutine\co(function () use ($wg, &$user_doctor, $doctor_id) {
co(function () use ($wg, &$user_doctor, $doctor_id) {
$params = array();
$params['doctor_id'] = $doctor_id;
$user_doctor = UserDoctor::getOne($params);
@ -278,7 +272,7 @@ class OrderPrescriptionService extends BaseService
});
// 获取医生详情数据
Coroutine\co(function () use ($wg, &$user_doctor_info, $doctor_id) {
co(function () use ($wg, &$user_doctor_info, $doctor_id) {
$params = array();
$params['doctor_id'] = $doctor_id;
$user_doctor_info = UserDoctorInfo::getOne($params);
@ -288,7 +282,7 @@ class OrderPrescriptionService extends BaseService
});
// 获取药师数据
Coroutine\co(function () use ($wg, &$user_pharmacist, $pharmacist_id) {
co(function () use ($wg, &$user_pharmacist, $pharmacist_id) {
$params = array();
$params['pharmacist_id'] = $pharmacist_id;
$user_pharmacist = UserPharmacist::getOne($params);
@ -298,7 +292,7 @@ class OrderPrescriptionService extends BaseService
});
// 获取药师详情数据
Coroutine\co(function () use ($wg, &$user_pharmacist_info, $pharmacist_id) {
co(function () use ($wg, &$user_pharmacist_info, $pharmacist_id) {
$params = array();
$params['pharmacist_id'] = $pharmacist_id;
$user_pharmacist_info = UserPharmacistInfo::getOne($params);
@ -308,7 +302,7 @@ class OrderPrescriptionService extends BaseService
});
// 获取病例数据
Coroutine\co(function () use ($wg, &$order_inquiry_case, $order_inquiry_id) {
co(function () use ($wg, &$order_inquiry_case, $order_inquiry_id) {
$params = array();
$params['order_inquiry_id'] = $order_inquiry_id;
$params['status'] = 1;
@ -318,29 +312,6 @@ class OrderPrescriptionService extends BaseService
$wg->done();
});
// 获取药品订单优惠券数据
Coroutine\co(function () use ($wg, &$product_coupons, $order_product_id) {
$params = array();
$params['order_product_id'] = $order_product_id;
$order_product_coupons = OrderProductCoupon::getList($params);
foreach ($order_product_coupons as $order_product_coupon){
$params = array();
$params['user_coupon_id'] = $order_product_coupon['user_coupon_id'];
$user_coupon = UserCoupon::getOne($params);
if (!empty($user_coupon)){
$params = array();
$params['coupon_id'] = $user_coupon['coupon_id'];
$coupon = Coupon::getOne($params);
if (!empty($coupon)){
$product_coupons[] = $coupon->toArray();
}
}
}
// 计数器减一
$wg->done();
});
$wg->wait();
if (empty($user)) {
@ -467,12 +438,8 @@ class OrderPrescriptionService extends BaseService
$arg['presList'][0]['orderDrugList'][$key]['price'] = $product['product_price']; // 药品单价
$arg['presList'][0]['orderDrugList'][$key]['drugCount'] = $item['amount']; // 药品数量
$arg['presList'][0]['orderDrugList'][$key]['packingUnit'] = $product['packaging_unit']; // 药品单位
$arg['presList'][0]['orderDrugList'][$key]['actualSellingPrice'] = $item['actual_product_price']; // 药品实际销售单价
}
// 处理上报处方平台药品优惠券相关数据
$arg['promotion'] = $this->handleReportPrescriptionProductCouponData($product_coupons,$order_product_item,$order_product['order_product_no']);
$Prescription = new Prescription();
$result = $Prescription->reportPrescription($arg);
if ($result['resultCode'] != "1000"){
@ -522,50 +489,4 @@ class OrderPrescriptionService extends BaseService
throw new BusinessException($e->getMessage());
}
}
/**
* 处理上报处方平台药品优惠券相关数据
* @param array $product_coupons 药品订单优惠券为coupon数据
* @param array|object $order_product_item 药品订单明细
* @param string $orderNo 药品订单编号
* @return array
*/
public function handleReportPrescriptionProductCouponData(array $product_coupons,array|object $order_product_item,string $orderNo): array
{
$promotion = array();
if (empty($product_coupons)){
return $promotion;
}
foreach ($product_coupons as $product_coupon){
// 适用范围1:全场通用 2:问诊 3:按品牌适用 4:按类别适用 5:单品使用 6:全品类药品)
if ($product_coupon["application_scope"] == 1 || $product_coupon["application_scope"] == 6){
$result = array();
$result["type"] = "orderCoupons";
$result["objectId"] = $orderNo;
$result["amount"] = $product_coupon["coupon_price"]; // 优惠金额
$result["count"] = 1;
$promotion[] = $result;
}
if ($product_coupon["application_scope"] == 5){
$product_ids = explode(',',$product_coupon['product_id']);
foreach ($order_product_item as $value){
if (in_array($value['product_id'],$product_ids)){
$result = array();
$result["type"] = "productCoupons";
$result["objectId"] = $value['product_platform_code'];
$result["amount"] = bcsub($value["product_price"],$value["actual_product_price"],2); // 优惠金额
$result["count"] = 1;
$promotion[] = $result;
}
}
}
}
return $promotion;
}
}

View File

@ -647,19 +647,7 @@ class PatientOrderService extends BaseService
}
// 处理优惠金额
$order_product['discount_amount'] = bcsub(
bcsub(
bcadd(
$order_product['amount_total'],
$order_product['logistics_fee']
,2
),
$order_product['coupon_amount_total'],
2
),
$order_product['payment_amount_total'],
2
); // 优惠金额
$order_product['discount_amount'] = $order_product['amount_total'] + $order_product['logistics_fee'] - $order_product['coupon_amount_total'] - $order_product['payment_amount_total']; // 优惠金额
$result = array();
@ -934,20 +922,7 @@ class PatientOrderService extends BaseService
$result['amount_total'] = $order_product['amount_total']; // 订单金额
$result['payment_amount_total'] = $order_product['payment_amount_total']; // 实际订单金额
$result['coupon_amount_total'] = $order_product['coupon_amount_total']; // 优惠金额
$result['discount_amount'] =
bcsub(
bcadd(
bcsub(
$order_product['amount_total'],
$order_product['coupon_amount_total'],
2
),
$order_product['logistics_fee'],
2
),
$order_product['payment_amount_total'],
2
); // 优惠金额
$result['discount_amount'] = $order_product['amount_total'] - $order_product['coupon_amount_total'] + $order_product['logistics_fee'] - $order_product['payment_amount_total']; // 优惠金额
// 获取优惠卷不可用原因。存在优惠卷,但是未使用-暂时废弃
/*if ($order_product['coupon_amount_total'] == 0){
@ -3525,14 +3500,6 @@ class PatientOrderService extends BaseService
}
}
foreach ($product_datas as &$product_data){
$product_data["actual_product_price"] = bcdiv(
$product_data['actual_product_price'],
$product_data['actual_quantity'],
2
);
}
return $product_datas;
}
}

View File

@ -84,11 +84,11 @@ class UserCouponService extends BaseService
/**
* 获取可用优惠卷总金额
* @param array $coupons 优惠卷数据
* @return string
* @return int
*/
public function getCouponTotalPrice(array $coupons): string
public function getCouponTotalPrice(array $coupons): int
{
$coupon_total_price = "0";
$coupon_total_price = 0;
foreach ($coupons as $coupon){
$coupon_total_price = bcadd($coupon_total_price,$coupon['coupon_price'],2);

2955
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -366,6 +366,7 @@ abstract class Ca
throw new BusinessException($response->getBody()->getContents());
}
$body = json_decode($response->getBody(), true);
dump($body);
if (empty($body)) {
// 返回值为空
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));