From 8aa441214dd1886d199ab3b4eb1ff74a6bd40573 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 23 May 2024 16:31:04 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=BC=95=E5=85=A5=E4=BA=86=20`OrderEnum`?= =?UTF-8?q?=20=E6=9E=9A=E4=B8=BE=E7=B1=BB=EF=BC=8C=202.=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BA=86=E8=AE=A2=E5=8D=95=E5=8F=B7=E7=9A=84=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=96=B9=E5=BC=8F=EF=BC=8C=203.=20=E5=BC=95=E5=85=A5?= =?UTF-8?q?=E4=BA=86=20`FinancialRecord`=20=E6=A8=A1=E5=9E=8B=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E5=88=9B=E5=BB=BA=E4=BA=86=E6=96=B0=E7=9A=84=E8=B4=A2?= =?UTF-8?q?=E5=8A=A1=E8=AE=B0=E5=BD=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logic/operation/OpurchaseclassLogic.php | 68 ++++++++++++------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/app/admin/logic/operation/OpurchaseclassLogic.php b/app/admin/logic/operation/OpurchaseclassLogic.php index 79c7a4c..875fa03 100644 --- a/app/admin/logic/operation/OpurchaseclassLogic.php +++ b/app/admin/logic/operation/OpurchaseclassLogic.php @@ -2,9 +2,10 @@ namespace app\admin\logic\operation; - +use app\common\enum\OrderEnum; use app\common\model\operation\Opurchaseclass; use app\common\logic\BaseLogic; +use app\common\model\financial\FinancialRecord; use app\common\model\goods\Goods; use app\common\model\merchant\Merchant; use app\common\model\opurchase\OpurchaseGoodsOffer; @@ -64,7 +65,7 @@ class OpurchaseclassLogic extends BaseLogic } $order = [ 'time' => time(), - 'number' => static::getNewOrderId('CG'), + 'number' => getNewOrderId('CG'), 'total' => array_sum(array_column($cart_select, 'total')), 'pay_type' => $params['pay_type'] ?? 0, 'cart_id' => implode(',', $cart_arr), @@ -196,10 +197,10 @@ class OpurchaseclassLogic extends BaseLogic public static function createSupplierGoods($goods) { try { - $supplier_arr = SupplierBindGoods::where('goods_id',$goods['goods'])->column('supplier_id'); + $supplier_arr = SupplierBindGoods::where('goods_id', $goods['goods'])->column('supplier_id'); if ($supplier_arr) { $supplier_arr = array_unique($supplier_arr); - $time=strtotime(date('Y-m-d',time())); + $time = strtotime(date('Y-m-d', time())); foreach ($supplier_arr as $k => $v) { $goods_offer[] = [ 'supplier_id' => $v, @@ -209,11 +210,11 @@ class OpurchaseclassLogic extends BaseLogic 'need_num' => $goods['nums'], 'create_time' => time() ]; - $find=Db::name('opurchase_goods_offer_date')->where('supplier_id',$v)->where('create_time',$time)->find(); - if($find){ - Db::name('opurchase_goods_offer_date')->where('id',$find['id'])->inc('nums')->update(); - }else{ - $data=['supplier_id'=>$v,'nums'=>1,'create_time'=>$time]; + $find = Db::name('opurchase_goods_offer_date')->where('supplier_id', $v)->where('create_time', $time)->find(); + if ($find) { + Db::name('opurchase_goods_offer_date')->where('id', $find['id'])->inc('nums')->update(); + } else { + $data = ['supplier_id' => $v, 'nums' => 1, 'create_time' => $time]; Db::name('opurchase_goods_offer_date')->insert($data); } } @@ -253,6 +254,40 @@ class OpurchaseclassLogic extends BaseLogic $find->notes = $notes; $find->before_nums = $find->nums; $find->nums = $nums; + $price=0; + if ($nums != 0) { + $price = bcmul($find['price'], $nums, 2); + Supplier::where('id', $id)->inc('mer_money', $price)->update(); + } + $number=Opurchaseclass::where('id',$find['order_id'])->value('number'); + $time=time(); + //平台支出 + $record[] = [ + 'financial_record_sn' => $time, + 'order_id' => $find['order_id'], + 'number_sn' => $number, + 'user_id' => 0, + 'financial_type' => OrderEnum::PLATFORM_ORDER_PAY, + 'financial_pm' => OrderEnum::EXPENDITURE, + 'number' => $price, + 'status' => 1, + 'type' => OrderEnum::USER, + 'mer_id' => getenv('OPERATED') + ]; + //供应链获得流水 + $record[] = [ + 'financial_record_sn' => $time, + 'order_id' => $find['order_id'], + 'number_sn' => $number, + 'user_id' => 0, + 'financial_type' => OrderEnum::PLATFORM_ORDER_OBTAINS, + 'financial_pm' => OrderEnum::INCOME, + 'number' => $price, + 'status' => 1, + 'type' => OrderEnum::SUPPLIER, + 'mer_id' => $find['supplier_id'], + ]; + (new FinancialRecord())->saveAll($record); } $res = $find->save(); if ($res) { @@ -264,19 +299,4 @@ class OpurchaseclassLogic extends BaseLogic return false; } } - - /** - * @notes 获取订单号 - * @param $type - * @return string - * @author likeadmin - * @date 2021/7/28 17:05 - */ - static public function getNewOrderId($type) - { - list($msec, $sec) = explode(' ', microtime()); - $msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', ''); - $orderId = $type . $msectime . mt_rand(10000, max(intval($msec * 10000) + 10000, 98369)); - return $orderId; - } }