修改商品订单金额计算1
This commit is contained in:
parent
5811ab949d
commit
3470cd2aaa
@ -1473,6 +1473,7 @@ class PatientOrderService extends BaseService
|
|||||||
$product_datas = array(); // 商品数据
|
$product_datas = array(); // 商品数据
|
||||||
$discount_amount = 0;// 优惠金额
|
$discount_amount = 0;// 优惠金额
|
||||||
$freight_calculation_amount = 0; // 药品总金额-计算运费使用
|
$freight_calculation_amount = 0; // 药品总金额-计算运费使用
|
||||||
|
$payment_amount_total = 0; // 支付金额
|
||||||
|
|
||||||
foreach ($product_ids as $product_id) {
|
foreach ($product_ids as $product_id) {
|
||||||
// 检测药品是否存在于处方中
|
// 检测药品是否存在于处方中
|
||||||
@ -1503,6 +1504,12 @@ class PatientOrderService extends BaseService
|
|||||||
// 获取订单金额
|
// 获取订单金额
|
||||||
$amount_total = bcadd($amount_total, ($product['product_price'] * $order_prescription_product['prescription_product_num']), 2);
|
$amount_total = bcadd($amount_total, ($product['product_price'] * $order_prescription_product['prescription_product_num']), 2);
|
||||||
|
|
||||||
|
// 药品总金额-计算运费使用
|
||||||
|
$freight_calculation_amount = $amount_total;
|
||||||
|
|
||||||
|
// 支付金额
|
||||||
|
$payment_amount_total = $amount_total;
|
||||||
|
|
||||||
// 商品数据
|
// 商品数据
|
||||||
$product['product_num'] = $order_prescription_product['prescription_product_num'];
|
$product['product_num'] = $order_prescription_product['prescription_product_num'];
|
||||||
$product['used_quantity'] = 0; // 健康包服务下已使用赠送药品的数量,默认赋0
|
$product['used_quantity'] = 0; // 健康包服务下已使用赠送药品的数量,默认赋0
|
||||||
@ -1539,12 +1546,15 @@ class PatientOrderService extends BaseService
|
|||||||
// 处理商品数量
|
// 处理商品数量
|
||||||
$OrderServicePackageService = new OrderServicePackageService();
|
$OrderServicePackageService = new OrderServicePackageService();
|
||||||
|
|
||||||
// 处理商品数量、金额,重新赋0,上面已计算过
|
// 商品金额,重新赋0,上面已计算过
|
||||||
$amount_total = 0;
|
$amount_total = 0;
|
||||||
|
|
||||||
// 药品总金额-计算运费使用,重新赋0,上面已计算过
|
// 药品总金额-计算运费使用,重新赋0,上面已计算过
|
||||||
$freight_calculation_amount = 0;
|
$freight_calculation_amount = 0;
|
||||||
|
|
||||||
|
// 支付金额
|
||||||
|
$payment_amount_total = 0;
|
||||||
|
|
||||||
foreach ($product_datas as $key => $product_data) {
|
foreach ($product_datas as $key => $product_data) {
|
||||||
// 获取服务包内某一药品的总数量
|
// 获取服务包内某一药品的总数量
|
||||||
$total_quantity = $OrderServicePackageService->getOrderServiceProductTotalQuantity($order_service_package_detail['package_id'], $product_data['product_id']);
|
$total_quantity = $OrderServicePackageService->getOrderServiceProductTotalQuantity($order_service_package_detail['package_id'], $product_data['product_id']);
|
||||||
@ -1552,9 +1562,6 @@ class PatientOrderService extends BaseService
|
|||||||
// 获取服务包内某一药品的剩余数量
|
// 获取服务包内某一药品的剩余数量
|
||||||
$remaining_quantity = $OrderServicePackageService->getOrderServiceProductCanUseQuantity($order_service_package['order_service_id'], $product_data['product_id'], $total_quantity);
|
$remaining_quantity = $OrderServicePackageService->getOrderServiceProductCanUseQuantity($order_service_package['order_service_id'], $product_data['product_id'], $total_quantity);
|
||||||
|
|
||||||
// 实际药品价格
|
|
||||||
$actual_product_price = 0;
|
|
||||||
|
|
||||||
// 可用数量大于处方商品数量
|
// 可用数量大于处方商品数量
|
||||||
if ($remaining_quantity >= $product_data['product_num']) {
|
if ($remaining_quantity >= $product_data['product_num']) {
|
||||||
// 药品优惠金额
|
// 药品优惠金额
|
||||||
@ -1589,6 +1596,17 @@ class PatientOrderService extends BaseService
|
|||||||
),
|
),
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 此处重新计算药品支付金额
|
||||||
|
$payment_amount_total = bcadd(
|
||||||
|
$payment_amount_total,
|
||||||
|
bcmul(
|
||||||
|
$product_datas[$key]['product_price'],
|
||||||
|
$product_datas[$key]['actual_quantity'],
|
||||||
|
2
|
||||||
|
),
|
||||||
|
2
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 此处重新计算药品总金额
|
// 此处重新计算药品总金额
|
||||||
@ -1599,17 +1617,15 @@ class PatientOrderService extends BaseService
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 此处重新计算药品优惠金额
|
// 此处重新计算药品优惠金额
|
||||||
if ($discount_amount > 0){
|
$discount_amount = bcadd(
|
||||||
$discount_amount = bcadd(
|
$discount_amount,
|
||||||
$discount_amount,
|
bcmul(
|
||||||
bcmul(
|
$product_datas[$key]['discount_amount'],
|
||||||
$product_datas[$key]['discount_amount'],
|
$product_datas[$key]['used_quantity'],
|
||||||
$product_datas[$key]['used_quantity'],
|
|
||||||
2
|
|
||||||
),
|
|
||||||
2
|
2
|
||||||
);
|
),
|
||||||
}
|
2
|
||||||
|
);
|
||||||
|
|
||||||
// 此处计算药品总金额-计算运费使用
|
// 此处计算药品总金额-计算运费使用
|
||||||
$freight_calculation_amount = bcadd(
|
$freight_calculation_amount = bcadd(
|
||||||
@ -1650,13 +1666,14 @@ class PatientOrderService extends BaseService
|
|||||||
// 实际支付金额=商品总金额-优惠卷金额+运费金额
|
// 实际支付金额=商品总金额-优惠卷金额+运费金额
|
||||||
$payment_amount_total = bcadd(
|
$payment_amount_total = bcadd(
|
||||||
bcsub(
|
bcsub(
|
||||||
$amount_total,
|
$payment_amount_total,
|
||||||
$coupon_amount_total,
|
$coupon_amount_total,
|
||||||
2
|
2
|
||||||
),
|
),
|
||||||
$logistics_fee,
|
$logistics_fee,
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($app_env == "dev") {
|
if ($app_env == "dev") {
|
||||||
if ($payment_amount_total > 0) {
|
if ($payment_amount_total > 0) {
|
||||||
$payment_amount_total = 0.01;
|
$payment_amount_total = 0.01;
|
||||||
@ -2082,6 +2099,7 @@ class PatientOrderService extends BaseService
|
|||||||
$product_datas = array(); // 商品数据
|
$product_datas = array(); // 商品数据
|
||||||
$discount_amount = 0;// 优惠金额
|
$discount_amount = 0;// 优惠金额
|
||||||
$freight_calculation_amount = 0; // 药品总金额-计算运费使用
|
$freight_calculation_amount = 0; // 药品总金额-计算运费使用
|
||||||
|
$payment_amount_total = 0; // 支付金额
|
||||||
|
|
||||||
foreach ($order_prescription_products as &$order_prescription_product) {
|
foreach ($order_prescription_products as &$order_prescription_product) {
|
||||||
$params = array();
|
$params = array();
|
||||||
@ -2107,6 +2125,9 @@ class PatientOrderService extends BaseService
|
|||||||
// 药品总金额-计算运费使用
|
// 药品总金额-计算运费使用
|
||||||
$freight_calculation_amount = $amount_total;
|
$freight_calculation_amount = $amount_total;
|
||||||
|
|
||||||
|
// 支付金额
|
||||||
|
$payment_amount_total = $amount_total;
|
||||||
|
|
||||||
// 处方药品数据
|
// 处方药品数据
|
||||||
$product['product_num'] = $order_prescription_product['prescription_product_num'];
|
$product['product_num'] = $order_prescription_product['prescription_product_num'];
|
||||||
$product['used_quantity'] = 0; // 已使用数量
|
$product['used_quantity'] = 0; // 已使用数量
|
||||||
@ -2141,6 +2162,9 @@ class PatientOrderService extends BaseService
|
|||||||
// 药品总金额-计算运费使用,重新赋0,上面已计算过
|
// 药品总金额-计算运费使用,重新赋0,上面已计算过
|
||||||
$freight_calculation_amount = 0;
|
$freight_calculation_amount = 0;
|
||||||
|
|
||||||
|
// 支付金额
|
||||||
|
$payment_amount_total = 0;
|
||||||
|
|
||||||
foreach ($product_datas as &$product_data) {
|
foreach ($product_datas as &$product_data) {
|
||||||
// 获取服务包内某一药品的总数量
|
// 获取服务包内某一药品的总数量
|
||||||
$total_quantity = $OrderServicePackageService->getOrderServiceProductTotalQuantity($order_service_package_detail['package_id'], $product_data['product_id']);
|
$total_quantity = $OrderServicePackageService->getOrderServiceProductTotalQuantity($order_service_package_detail['package_id'], $product_data['product_id']);
|
||||||
@ -2148,17 +2172,11 @@ class PatientOrderService extends BaseService
|
|||||||
// 获取服务包内某一药品的剩余数量
|
// 获取服务包内某一药品的剩余数量
|
||||||
$remaining_quantity = $OrderServicePackageService->getOrderServiceProductCanUseQuantity($order_service_package['order_service_id'], $product_data['product_id'], $total_quantity);
|
$remaining_quantity = $OrderServicePackageService->getOrderServiceProductCanUseQuantity($order_service_package['order_service_id'], $product_data['product_id'], $total_quantity);
|
||||||
|
|
||||||
// 实际药品价格
|
|
||||||
$actual_product_price = 0;
|
|
||||||
|
|
||||||
// 可用数量大于处方商品数量
|
// 可用数量大于处方商品数量
|
||||||
if ($remaining_quantity >= $product_data['product_num']) {
|
if ($remaining_quantity >= $product_data['product_num']) {
|
||||||
// 药品优惠金额
|
// 药品优惠金额
|
||||||
$product_data['discount_amount'] = $product_data['product_price'] - 35;
|
$product_data['discount_amount'] = $product_data['product_price'] - 35;
|
||||||
|
|
||||||
// 实际药品价格
|
|
||||||
$actual_product_price = 35 * $product_data['product_num'];
|
|
||||||
|
|
||||||
// 已使用数量 = 原数量+此次使用数量
|
// 已使用数量 = 原数量+此次使用数量
|
||||||
$product_data['used_quantity'] = $product_data['product_num'];
|
$product_data['used_quantity'] = $product_data['product_num'];
|
||||||
|
|
||||||
@ -2188,6 +2206,17 @@ class PatientOrderService extends BaseService
|
|||||||
),
|
),
|
||||||
2
|
2
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 此处重新计算药品支付金额
|
||||||
|
$payment_amount_total = bcadd(
|
||||||
|
$payment_amount_total,
|
||||||
|
bcmul(
|
||||||
|
$product_data['product_price'],
|
||||||
|
$product_data['actual_quantity'],
|
||||||
|
2
|
||||||
|
),
|
||||||
|
2
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 此处重新计算药品总金额
|
// 此处重新计算药品总金额
|
||||||
@ -2198,17 +2227,15 @@ class PatientOrderService extends BaseService
|
|||||||
);
|
);
|
||||||
|
|
||||||
// 此处重新计算药品优惠金额
|
// 此处重新计算药品优惠金额
|
||||||
if ($discount_amount > 0){
|
$discount_amount = bcadd(
|
||||||
$discount_amount = bcadd(
|
$discount_amount,
|
||||||
$discount_amount,
|
bcmul(
|
||||||
bcmul(
|
$product_data['discount_amount'],
|
||||||
$product_data['discount_amount'],
|
$product_data['used_quantity'],
|
||||||
$product_data['used_quantity'],
|
|
||||||
2
|
|
||||||
),
|
|
||||||
2
|
2
|
||||||
);
|
),
|
||||||
}
|
2
|
||||||
|
);
|
||||||
|
|
||||||
// 此处计算药品总金额-计算运费使用
|
// 此处计算药品总金额-计算运费使用
|
||||||
$freight_calculation_amount = bcadd(
|
$freight_calculation_amount = bcadd(
|
||||||
@ -2241,7 +2268,7 @@ class PatientOrderService extends BaseService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 实际支付金额=商品总金额-优惠卷金额+运费金额
|
// 实际支付金额=商品总金额-优惠卷金额+运费金额
|
||||||
$payment_amount_total = bcadd(bcsub($amount_total, $coupon_amount_total, 2), $logistics_fee, 2);
|
$payment_amount_total = bcadd(bcsub($payment_amount_total, $coupon_amount_total, 2), $logistics_fee, 2);
|
||||||
|
|
||||||
// 获取收货地址
|
// 获取收货地址
|
||||||
$params = array();
|
$params = array();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user