|
|
@@ -39,6 +39,11 @@ class PurchaseOrderClass extends BaseClass
|
|
|
const DEBT_YES = 1;
|
|
|
const DEBT_NO = 2;
|
|
|
|
|
|
+ //寄付与到付
|
|
|
+ const YF_PAY_WAY_JF = 1;
|
|
|
+ const YF_PAY_WAY_DF = 2;
|
|
|
+
|
|
|
+
|
|
|
//添加采购单 lqh 2021.1.19
|
|
|
public static function addOrder($data)
|
|
|
{
|
|
|
@@ -75,8 +80,8 @@ class PurchaseOrderClass extends BaseClass
|
|
|
$data['price'] = $totalItemPrice;
|
|
|
|
|
|
//包装重量 shish 20210614
|
|
|
- $data['packWeight'] = isset($data['packWeight']) && is_numeric($data['packWeight']) ? $data['packWeight'] : 0;
|
|
|
- $totalItemWeight = bcadd($totalItemWeight, $data['packWeight'], 2);
|
|
|
+ //$data['packWeight'] = isset($data['packWeight']) && is_numeric($data['packWeight']) ? $data['packWeight'] : 0;
|
|
|
+ //$totalItemWeight = bcadd($totalItemWeight, $data['packWeight'], 2);
|
|
|
|
|
|
//计算订单总价
|
|
|
$data['packingCharge'] = empty($data['packingCharge']) ? 0 : $data['packingCharge'];
|
|
|
@@ -93,14 +98,24 @@ class PurchaseOrderClass extends BaseClass
|
|
|
$longCharge = $data['longCharge'] ?? 0;
|
|
|
$pickCharge = $data['pickCharge'] ?? 0;
|
|
|
$localCharge = $data['localCharge'] ?? 0;
|
|
|
- $currentPrice = bcadd($totalItemPrice, $packingCharge, 2);
|
|
|
- $currentPrice = bcadd($currentPrice, $shortCharge, 2);
|
|
|
- $currentPrice = bcadd($currentPrice, $longCharge, 2);
|
|
|
- $currentPrice = bcadd($currentPrice, $pickCharge, 2);
|
|
|
- $currentPrice = bcadd($currentPrice, $localCharge, 2);
|
|
|
|
|
|
- $data['prePrice'] = $currentPrice;
|
|
|
+ //提货费和本地运费
|
|
|
+ $paidPrice = bcadd($localCharge, $pickCharge, 2);
|
|
|
|
|
|
+ $yfPayWay = $data['yfPayWay'] ?? self::YF_PAY_WAY_JF;
|
|
|
+ //打包费
|
|
|
+ $currentPrice = bcadd($totalItemPrice, $packingCharge, 2);
|
|
|
+ //寄付才算长途和短途运费
|
|
|
+ if ($yfPayWay == self::YF_PAY_WAY_JF) {
|
|
|
+ $currentPrice = bcadd($currentPrice, $shortCharge, 2);
|
|
|
+ $currentPrice = bcadd($currentPrice, $longCharge, 2);
|
|
|
+ } elseif ($yfPayWay == self::YF_PAY_WAY_DF) {
|
|
|
+ $paidPrice = bcadd($paidPrice, $shortCharge, 2);
|
|
|
+ $paidPrice = bcadd($paidPrice, $longCharge, 2);
|
|
|
+ } else {
|
|
|
+ util::fail('没有找到这个运费支付方式');
|
|
|
+ }
|
|
|
+ $data['prePrice'] = $currentPrice;
|
|
|
if (isset($data['modifyPrice'])) {
|
|
|
//报损减免后金额
|
|
|
$modifyPrice = $data['modifyPrice'] ?? 0;
|
|
|
@@ -117,6 +132,7 @@ class PurchaseOrderClass extends BaseClass
|
|
|
$data['actPrice'] = $currentPrice;
|
|
|
//实付款,扣除平台补贴
|
|
|
$data['realPrice'] = $currentPrice;
|
|
|
+ $data['paidPrice'] = $paidPrice;
|
|
|
|
|
|
//总运费
|
|
|
$totalFreight = bcadd($packingCharge, $shortCharge, 2);
|
|
|
@@ -124,10 +140,6 @@ class PurchaseOrderClass extends BaseClass
|
|
|
$totalFreight = bcadd($totalFreight, $pickCharge, 2);
|
|
|
$totalFreight = bcadd($totalFreight, $localCharge, 2);
|
|
|
|
|
|
- if ($totalFreight <= 0) {
|
|
|
- util::fail('请填写运费');
|
|
|
- }
|
|
|
-
|
|
|
$connection = Yii::$app->db;
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
|