diff --git a/app/common/enum/OrderEnum.php b/app/common/enum/OrderEnum.php index 9c8a5c8f..1ffb751c 100644 --- a/app/common/enum/OrderEnum.php +++ b/app/common/enum/OrderEnum.php @@ -46,6 +46,7 @@ class OrderEnum const CASHIER_FACE_PAY = 17;//现金收银 const PURCHASE_FUNDS = 18;//采购款收银 + const PAY_BACK =-1; /** diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index bde01d35..c894fd40 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -293,11 +293,38 @@ class PayNotifyLogic extends BaseLogic } //微信日志 user_order_refund $capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money,'',1); + //处理财务流水退还 + self::store_finance_back($orderSn); self::addStock($order['id']);//微信 // self::afterPay($order,$extra['transaction_id']); } + + /** + * 财务退还金额相关 + * @param $orderSn + * @return void + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public static function store_finance_back($orderSn) + { + $data = StoreFinanceFlow::where('order_sn',$orderSn) + ->where(['financial_pm'=>1]) + ->select()->toArray(); + foreach ($data as &$value){ + unset($value['id']); + $value['financial_record_sn']=(new StoreFinanceFlowLogic)->getSn(); + $value['financial_pm']=0; + $value['financial_type']= OrderEnum::PAY_BACK; + $value['create_time']=time(); + } + (new StoreFinanceFlow)->saveAll($data); + + } + /** * 现金退款相关 * @param $orderSn