支付方式修改
This commit is contained in:
@@ -4,6 +4,7 @@ namespace common\forms;
|
||||
|
||||
use common\core\BaseModel;
|
||||
use common\models\newDb\AccountBalanceModel;
|
||||
use common\models\newDb\MonthlyPaymentModel;
|
||||
use common\models\oldDb\CashAccount;
|
||||
use common\models\oldDb\Ledger;
|
||||
use common\models\oldDb\LedgerLog;
|
||||
@@ -30,6 +31,12 @@ class LedgerForm extends BaseModel
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单分账
|
||||
* @param $type
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function create($type = 'productorder'){
|
||||
switch ($type) {
|
||||
case 'register':
|
||||
@@ -81,7 +88,7 @@ class LedgerForm extends BaseModel
|
||||
ProductOrderLog::saveLog($this->order_id, '产品订单增加待结算记录开始');
|
||||
$t = \Yii::$app->db->beginTransaction();
|
||||
try {
|
||||
$productOrder = ProductOrder::find()->where(['id' => $this->order_id])->one();
|
||||
$productOrder = ProductOrder::find()->with(['prescription'])->where(['id' => $this->order_id])->one();
|
||||
if(!$productOrder){
|
||||
throw new Exception('产品订单不存在');
|
||||
}
|
||||
@@ -95,6 +102,7 @@ class LedgerForm extends BaseModel
|
||||
}
|
||||
$time = time();
|
||||
$ledgerData = [];
|
||||
|
||||
if($productOrder->decoct_price > 0){
|
||||
$ledgerData[] = [
|
||||
'order_id' => $this->order_id,
|
||||
@@ -183,6 +191,15 @@ class LedgerForm extends BaseModel
|
||||
$totalPrice = round($number * $v['price'], 4);
|
||||
$totalBuyPrice = round($number * $v['buy_price'], 4);
|
||||
|
||||
if ($productOrder['prescription']['category'] == 2) {
|
||||
(new MonthlyPaymentModel)->save([
|
||||
'store_id' => $productOrder->store_id,
|
||||
'order_id' => $productOrder->id,
|
||||
'amount' => $totalBuyPrice,
|
||||
'created_at' => $time,
|
||||
]);
|
||||
|
||||
} else {
|
||||
$ledger[] = [
|
||||
'order_id' => $this->order_id,
|
||||
'user_id' => $store->id,
|
||||
@@ -221,12 +238,21 @@ class LedgerForm extends BaseModel
|
||||
'drug_id','xd_time', 'number', 'money', 'status', 'created_at', 'updated_at'
|
||||
], $ledger)->execute();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '2': //西药分佣
|
||||
$ledger = [];
|
||||
foreach($productOrderItems as $v){
|
||||
$totalPrice = round($v['number'] * $v['price'], 4);
|
||||
$totalBuyPrice = round($v['number'] * $v['buy_price'], 4);
|
||||
if ($productOrder['prescription']['category'] == 2) {
|
||||
(new MonthlyPaymentModel)->save([
|
||||
'store_id' => $productOrder->store_id,
|
||||
'order_id' => $productOrder->id,
|
||||
'amount' => $totalBuyPrice,
|
||||
'created_at' => $time,
|
||||
]);
|
||||
} else {
|
||||
$ledger[] = [
|
||||
'order_id' => $this->order_id,
|
||||
'user_id' => $store->id,
|
||||
@@ -265,6 +291,7 @@ class LedgerForm extends BaseModel
|
||||
'drug_id','xd_time', 'number','money', 'status', 'created_at', 'updated_at'
|
||||
], $ledger)->execute();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case '5':
|
||||
|
||||
19
common/models/newDb/MonthlyPaymentModel.php
Normal file
19
common/models/newDb/MonthlyPaymentModel.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace common\models\newDb;
|
||||
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
|
||||
class MonthlyPaymentModel extends \common\modelsgii\newDb\MonthlyPaymentModelGii
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'class' => TimestampBehavior::class,
|
||||
'attributes' => [
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
49
common/modelsgii/newDb/MonthlyPaymentModelGii.php
Normal file
49
common/modelsgii/newDb/MonthlyPaymentModelGii.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace common\modelsgii\newDb;
|
||||
|
||||
/**
|
||||
* This is the model class for table "yii_address".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property string $name
|
||||
* @property string $mobile
|
||||
* @property string $province 省
|
||||
* @property string $city 市
|
||||
* @property string $area 区
|
||||
* @property string $region 省市区
|
||||
* @property string $detail_address 详细地址
|
||||
* @property int $is_default 是否默认地址0否1是
|
||||
* @property int $created_at
|
||||
* @property int $updated_at
|
||||
* @property int $deleted_at
|
||||
*/
|
||||
class MonthlyPaymentModelGii extends \common\core\BaseNewActiveRecord
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%monthly_payment}}';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user