Compare commits
107 Commits
8afd0d91ed
...
ad9e345eb3
| Author | SHA1 | Date | |
|---|---|---|---|
| ad9e345eb3 | |||
| 23d9c4dbfb | |||
| defa12d98f | |||
| 5ad82a4864 | |||
| 920228fe48 | |||
| 3cd1d53f4a | |||
| 2f92ef3dfc | |||
| 2fa7762d54 | |||
| b961436de3 | |||
| 8443af52ee | |||
| 714fec7f82 | |||
| 6a936a8222 | |||
| d3c139a95e | |||
| 69d2e730c9 | |||
| ab58fb9326 | |||
| c2fdcd6d8b | |||
| bdd1af5bb3 | |||
| fea5e0f3b8 | |||
| d1b796861f | |||
| 276474cbfb | |||
| d7dd93ac6a | |||
| f05f8e911a | |||
| 2c21fbc6f1 | |||
| 4e6ad0de73 | |||
| 9caeca4563 | |||
| 973b1bb63c | |||
| e723994064 | |||
| 2729e33506 | |||
| 7f4dc5a78c | |||
| b9df31e447 | |||
| 1668c5382c | |||
| 8b4c7cc17a | |||
| 831e59842a | |||
| 0d173902e8 | |||
| af0f03f7e8 | |||
| e0e7338a38 | |||
| ab7f8ad295 | |||
| 9b4bc2a51a | |||
| 4dda3ada59 | |||
| aaf8ae7218 | |||
| a12746fe3e | |||
| 832b9e6996 | |||
| 89ca8470d8 | |||
| b4d96fd5f5 | |||
| 80c5d22e2e | |||
| a583a9fdda | |||
| 1d16a1265b | |||
| bb60464a57 | |||
| f57a1720d2 | |||
| 8cbbd848f3 | |||
| 3d38ed9da4 | |||
| b63077b223 | |||
| 01ccb8f2c8 | |||
| 3b4e01002e | |||
| 6de18e1eed | |||
| ff085a574f | |||
| 2f34fd18ae | |||
| 4f606c9c98 | |||
| 516eee9738 | |||
| bc28579e3e | |||
| 9a03cb3962 | |||
| 592f9cb7b4 | |||
| c16cc485cd | |||
| 17d908ec86 | |||
| 98c9e0a00b | |||
| 73eb50a478 | |||
| 9f8dd7c17c | |||
| ba8abec869 | |||
| b784512a0e | |||
| 3f429387b2 | |||
| d531315fbb | |||
| 1ae16fa641 | |||
| 89bc9dec11 | |||
| b8f835c953 | |||
| a55568e177 | |||
| 074948594a | |||
| 05631a64c3 | |||
| 29c3a2891d | |||
| fcb5bf7c52 | |||
| d249f314cd | |||
| 1e1070fe1e | |||
| fea52fb0c9 | |||
| 1956efb874 | |||
| 4b3d5970a1 | |||
| 4b791f4aa5 | |||
| 2b1f04e88f | |||
| 0e94079b56 | |||
| 0947ac856d | |||
| f82a70f2e8 | |||
| 44e4e48ded | |||
| 21a53b23c9 | |||
| 9131bddc51 | |||
| 7c02d9d82c | |||
| a631c70af9 | |||
| 496cf1b407 | |||
| 3bac586a0f | |||
| 0c9755d654 | |||
| 65ec7fba85 | |||
| d56f3b5a68 | |||
| e18fd8df22 | |||
| 8cf5b29953 | |||
| 1eaa0344c0 | |||
| 46c923d74b | |||
| 22e09e2cc8 | |||
| 9c7c371f1a | |||
| b21a51af0c | |||
| 1dfcc5660f |
@ -327,7 +327,7 @@ class TestController extends AbstractController
|
||||
// }
|
||||
// dump(111);
|
||||
|
||||
// // 测试药师
|
||||
// 测试药师
|
||||
// $data = array();
|
||||
// $data['user_id'] = "534534546";
|
||||
// $data['mobile'] = "18812345678";
|
||||
@ -351,25 +351,27 @@ class TestController extends AbstractController
|
||||
// }
|
||||
|
||||
// 测试医院
|
||||
$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();
|
||||
}
|
||||
// $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();
|
||||
// }
|
||||
return 111;
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $message_id 主键id
|
||||
* @property int $from_user_id 发送方user_id
|
||||
* @property string $from_user_id 发送方user_id
|
||||
* @property int $to_user_id 接收方user_id
|
||||
* @property string $message_key 消息唯一标识(系统返回,撤回消息使用)
|
||||
* @property string $message_send_time 消息发送时间戳
|
||||
|
||||
@ -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
|
||||
|
||||
@ -6,6 +6,8 @@ namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Database\Model\Relations\HasOne;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
@ -14,8 +16,8 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @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 修改时间
|
||||
* @property Carbon $created_at 创建时间
|
||||
* @property Carbon $updated_at 修改时间
|
||||
*/
|
||||
class OrderProductCoupon extends Model
|
||||
{
|
||||
@ -33,6 +35,14 @@ 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
|
||||
|
||||
@ -41,7 +41,7 @@ class UserCoupon extends Model
|
||||
protected string $primaryKey = "user_coupon_id";
|
||||
|
||||
/**
|
||||
* 关联医院表
|
||||
* 关联优惠券表
|
||||
*/
|
||||
public function Coupon(): HasOne
|
||||
{
|
||||
|
||||
@ -4,9 +4,11 @@ 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;
|
||||
@ -17,6 +19,7 @@ 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;
|
||||
@ -28,11 +31,12 @@ use Extend\Ca\CaOffline;
|
||||
use Extend\Ca\CaOnline;
|
||||
use Extend\Prescription\Prescription;
|
||||
use Hyperf\Contract\LengthAwarePaginatorInterface;
|
||||
use Hyperf\Utils\WaitGroup;
|
||||
use \Hyperf\Coroutine\WaitGroup;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Swoole\Coroutine\Channel;
|
||||
use TCPDF;
|
||||
use Hyperf\Coroutine;
|
||||
|
||||
class OrderPrescriptionService extends BaseService
|
||||
{
|
||||
@ -214,7 +218,7 @@ class OrderPrescriptionService extends BaseService
|
||||
}
|
||||
|
||||
$wg = new WaitGroup();
|
||||
$wg->add(8);
|
||||
$wg->add(9);
|
||||
|
||||
$user = []; // 就诊患者用户数据
|
||||
$patient_family = []; // 家庭成员-基本信息
|
||||
@ -224,15 +228,17 @@ 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'];
|
||||
|
||||
// 获取就诊患者用户数据
|
||||
co(function () use ($wg, &$user, $user_id) {
|
||||
Coroutine\co(function () use ($wg, &$user, $user_id) {
|
||||
$params = array();
|
||||
$params['user_id'] = $user_id;
|
||||
$user = User::getOne($params)->toArray();
|
||||
@ -241,7 +247,7 @@ class OrderPrescriptionService extends BaseService
|
||||
});
|
||||
|
||||
// 获取家庭成员-基本信息
|
||||
co(function () use ($wg, &$patient_family, $family_id) {
|
||||
Coroutine\co(function () use ($wg, &$patient_family, $family_id) {
|
||||
$params = array();
|
||||
$params['family_id'] = $family_id;
|
||||
$patient_family = PatientFamily::getOne($params);
|
||||
@ -252,7 +258,7 @@ class OrderPrescriptionService extends BaseService
|
||||
|
||||
// 获取处方关联疾病数据
|
||||
$order_prescription_id = $order_prescription['order_prescription_id'];
|
||||
co(function () use ($wg, &$order_prescription_icd, $order_prescription_id) {
|
||||
Coroutine\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);
|
||||
@ -262,7 +268,7 @@ class OrderPrescriptionService extends BaseService
|
||||
});
|
||||
|
||||
// 获取医生数据
|
||||
co(function () use ($wg, &$user_doctor, $doctor_id) {
|
||||
Coroutine\co(function () use ($wg, &$user_doctor, $doctor_id) {
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
@ -272,7 +278,7 @@ class OrderPrescriptionService extends BaseService
|
||||
});
|
||||
|
||||
// 获取医生详情数据
|
||||
co(function () use ($wg, &$user_doctor_info, $doctor_id) {
|
||||
Coroutine\co(function () use ($wg, &$user_doctor_info, $doctor_id) {
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$user_doctor_info = UserDoctorInfo::getOne($params);
|
||||
@ -282,7 +288,7 @@ class OrderPrescriptionService extends BaseService
|
||||
});
|
||||
|
||||
// 获取药师数据
|
||||
co(function () use ($wg, &$user_pharmacist, $pharmacist_id) {
|
||||
Coroutine\co(function () use ($wg, &$user_pharmacist, $pharmacist_id) {
|
||||
$params = array();
|
||||
$params['pharmacist_id'] = $pharmacist_id;
|
||||
$user_pharmacist = UserPharmacist::getOne($params);
|
||||
@ -292,7 +298,7 @@ class OrderPrescriptionService extends BaseService
|
||||
});
|
||||
|
||||
// 获取药师详情数据
|
||||
co(function () use ($wg, &$user_pharmacist_info, $pharmacist_id) {
|
||||
Coroutine\co(function () use ($wg, &$user_pharmacist_info, $pharmacist_id) {
|
||||
$params = array();
|
||||
$params['pharmacist_id'] = $pharmacist_id;
|
||||
$user_pharmacist_info = UserPharmacistInfo::getOne($params);
|
||||
@ -302,7 +308,7 @@ class OrderPrescriptionService extends BaseService
|
||||
});
|
||||
|
||||
// 获取病例数据
|
||||
co(function () use ($wg, &$order_inquiry_case, $order_inquiry_id) {
|
||||
Coroutine\co(function () use ($wg, &$order_inquiry_case, $order_inquiry_id) {
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry_id;
|
||||
$params['status'] = 1;
|
||||
@ -312,6 +318,29 @@ 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)) {
|
||||
@ -438,8 +467,12 @@ 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"){
|
||||
@ -489,4 +522,50 @@ 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;
|
||||
}
|
||||
}
|
||||
@ -647,7 +647,19 @@ class PatientOrderService extends BaseService
|
||||
}
|
||||
|
||||
// 处理优惠金额
|
||||
$order_product['discount_amount'] = $order_product['amount_total'] + $order_product['logistics_fee'] - $order_product['coupon_amount_total'] - $order_product['payment_amount_total']; // 优惠金额
|
||||
$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
|
||||
); // 优惠金额
|
||||
|
||||
|
||||
$result = array();
|
||||
@ -922,7 +934,20 @@ 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'] = $order_product['amount_total'] - $order_product['coupon_amount_total'] + $order_product['logistics_fee'] - $order_product['payment_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
|
||||
); // 优惠金额
|
||||
|
||||
// 获取优惠卷不可用原因。存在优惠卷,但是未使用-暂时废弃
|
||||
/*if ($order_product['coupon_amount_total'] == 0){
|
||||
@ -3500,6 +3525,14 @@ 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;
|
||||
}
|
||||
}
|
||||
@ -84,11 +84,11 @@ class UserCouponService extends BaseService
|
||||
/**
|
||||
* 获取可用优惠卷总金额
|
||||
* @param array $coupons 优惠卷数据
|
||||
* @return int
|
||||
* @return string
|
||||
*/
|
||||
public function getCouponTotalPrice(array $coupons): int
|
||||
public function getCouponTotalPrice(array $coupons): string
|
||||
{
|
||||
$coupon_total_price = 0;
|
||||
$coupon_total_price = "0";
|
||||
|
||||
foreach ($coupons as $coupon){
|
||||
$coupon_total_price = bcadd($coupon_total_price,$coupon['coupon_price'],2);
|
||||
|
||||
2951
composer.lock
generated
2951
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -366,7 +366,6 @@ 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));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user