ソースを参照

Merge branch 'master-new-wgg' of wugg/phpstock into master-new

wugg 4 ヶ月 前
コミット
570664e0c9
3 ファイル変更32 行追加42 行削除
  1. 7 14
      app/admin/controller/Goodup.php
  2. 24 10
      app/command/SplitSale.php
  3. 1 18
      app/command/handleYzOrderData.php

+ 7 - 14
app/admin/controller/Goodup.php

@@ -177,33 +177,25 @@ class Goodup extends Base
             ->column('unit','id');
         foreach ($list as $value){
                 $value["cat_info"]= made($value['cat_id'],[]);
-//                $brand=Db::name("brand")->where(["id"=>$value['brand_id']])->find();
                 $value["brand_name"]=$brand[$value['brand_id']]??'';//isset($brand['brand_name'])?$brand['brand_name']:"";
-//                $unit = Db::name("unit")->where(["id"=>$value['good_unit']])->find();
                 $value['unit'] =$unit[$value['good_unit']]??'';//isset($unit['unit'])?$unit['unit']:"";
-//                $company = Db::name("business")->where(["companyNo"=>$value['companyNo']])->find();
                 $value['company'] = $value['companyName'];//$supplierInfo['data'][$value['companyNo']]??'';//isset($company['company'])?$company['company']:"";
-//                $supplier = Db::name("supplier")->where(['code'=>$value['supplierNo']])->find();
                 $value['supplier_name']=$value['supplierName'];//$supplierInfo['data'][$value['supplierNo']]??'';//isset($supplier['name'])?$supplier['name']:"";
                 $value['exclusive']=makeExcluse($value['is_exclusive']);
                 $value['noble_name']=isset($value['noble_metal'])&&$value['noble_metal']!=0?$this->noble[$value['noble_metal']] :"";
-                $value['tax_info']=$value['tax_info']= GoodTax::with(['Tax'])
-                                            ->where(['spuCode' => $value['spuCode']])
-                                    ->visible(['in_tax_name', 'in_tax_code', 'in_tax_short', 'in_tax_merge', 'tax'])->findOrEmpty();
+                $value['tax_info']= GoodTax::with(['Tax',"OutTax"])
+                    ->where(['spuCode' => $value['spuCode']])
+                    ->visible(['tax_id','in_tax_name', 'in_tax_code', 'in_tax_short', 'in_tax_merge', 'tax','out_tax_id','out_tax_name',
+                        'out_tax_code', 'out_tax_short', 'out_tax_merge', 'out_tax'])
+                    ->findOrEmpty();
             //如果一个spucode在任意平台上线,那么就视为它上线,即手动把它的is_online值改为1
-           $value['is_online'] = 0;
+            $value['is_online'] = 0;
             if (isset($exam_statuss[$value['spuCode']]) || isset($exam_status_yz[$value['spuCode']])) $value['is_online'] = 1;
 			else $value['is_online'] = 0;
             $value['charger_company_name'] = $item[$value['chargerid']]??'';
-
             $value['has_account'] = (int)isset($account[$value['supplierNo']]);
-
             //是否具有编辑权限
             $value['is_allow_update'] = 1;
-//            if ($this->level == 2) {
-//                if (in_array($this->roleid, [1, 33]) || in_array($value['chargerid'], $role[DataGroupModel::$type_可编辑])) $value['is_allow_update'] = 1;
-//            } elseif ($this->level == 3) $value['is_allow_update'] = 1;
-
             $data[] = $value;
         }
         return app_show(0, "获取成功", ['count' => $count, 'list' => $data]);
@@ -3688,6 +3680,7 @@ class Goodup extends Base
 	  	if(isset($data['status']))unset($data['status']);
 	  	if(isset($data['charger']))unset($data['charger']);
 	  	if(isset($data['chargerid']))unset($data['chargerid']);
+        if(isset($data['is_syscn_tax']))unset($data['is_syscn_tax']);
 	  	$good->where($info->toArray())->save($data);
 	  }
 	}

+ 24 - 10
app/command/SplitSale.php

@@ -53,6 +53,7 @@ class SplitSale extends Command
                     ])->cursor();
                 $userCommon = User::getIns();
                 $commonOrder=[];//处理采购销售同一数据
+                $updatePrice=true;
                 foreach ($data as $sale) {
                 	//处理采购销售同一数据
                 	$tempOrder=[
@@ -77,6 +78,7 @@ class SplitSale extends Command
                 		];
 					if( strtotime($sale['addtime']) >= strtotime('2023-07-01 00:00:00'))$this->Tcode ='F';
 					else $this->Tcode ='';
+                    if( strtotime($sale['addtime']) >= strtotime('2024-12-12 23:59:59')) $updatePrice=false;
                     //补充商品信息
                     if ($sale['order_type'] == 3 ||$sale['order_type'] == 4) {
                         //咨询相关
@@ -122,7 +124,11 @@ class SplitSale extends Command
                         ->findOrEmpty();
 					
                     //采购总金额和销售总金额
-                    $cgd_total = $sale_total = $sale['total_price'];
+                    if($updatePrice) $cgd_total = $sale_total = $sale['total_price'];
+                   else {
+                       $cgd_price = $sale_price = $sale['sale_price'];
+                       $cgd_total = $sale_total = $sale['total_price'];
+                   }
 		            //客户
                     $customer = ['No' => $sale['customer_code'], 'name' => $sale['customerName']];
                    
@@ -135,17 +141,25 @@ class SplitSale extends Command
                         $orderCode = substr($orderCode, 0, -2) . str_pad($this->i, 2, '0', STR_PAD_LEFT);
                         $this->i++;
                         //计算渠道业务公司采购单单价。
-                        $cgd_total = bcsub($cgd_total, bcmul($sale['total_price'] ?? 0, round($pay_rate['rate'] / 100, 4), 5), 5);
+                       if($updatePrice)$cgd_total = bcsub($cgd_total, bcmul($sale['total_price'] ?? "0", round($pay_rate['rate'] / 100, 4), 5), 5);
+                       else {
+                           $cgd_price = bcsub($cgd_price, bcmul($sale_price ?? "0", round($pay_rate['rate'] / 100, 4), 8), 8);
+                           $cgd_total =bcmul($cgd_price, $sale['good_num'], 8);
+                       }
                         //此次销售单业务公司信息
 						$supplier = ['No' => $pay_rate['companyNo'], 'name' => $pay_rate['companyName'],"pay_name"=>$pay_rate['pay_name']];
-						$sale['origin_price'] = $sale['good_num'] > 0 ? bcdiv($cgd_total, $sale['good_num'], 5) : 0;
+						$sale['origin_price'] = $sale['good_num'] > 0 ? bcdiv($cgd_total, $sale['good_num'], 8) : "0";
                         $this->_handle_sale_caixiao($sale, $orderCode, $cgdNo, $sale_total, $customer, $supplier);
                         $tempOrder['customerName'] = $pay_rate['companyName'];
                         $tempOrder['customerNo'] = $pay_rate['companyNo'];
 						$this->_handle_cgd_caixiao($cgd, $sale, $pay_rate, $cgdNo, $orderCode, $cgd_total,$tempOrder);
 						//下一个渠道公司/原业务公司的 客户信息
 						$customer= ['No' => $pay_rate['companyNo'], 'name' => $pay_rate['companyName']];
-	                    $sale_total =$cgd_total; //下一个渠道公司/原业务公司的 销售价未此次的采购单价
+                        if($updatePrice) $sale_total =$cgd_total;
+                        else {
+                            $sale_price =$cgd_price;
+                            $sale_total = bcmul($cgd_price, $sale['good_num'], 8);
+                        } //下一个渠道公司/原业务公司的 销售价未此次的采购单价
 	                    //判断是否是最后一个渠道遍历。最后一次需要额外生成一个销售单给原业务公司;
 						if($keys == count($pay_rates)-1){
 							$orderCode = makeNo($this->Tcode.'QR');
@@ -212,10 +226,10 @@ class SplitSale extends Command
     }
 
     //构建销售单
-    private function _handle_sale_caixiao(array $sale = [], string $orderCode = '', string $cgdNo = '', float $sale_total = 0.00, array $customer = [], array $supplier = [],array &$tempOrder=[])
+    private function _handle_sale_caixiao(array $sale = [], string $orderCode = '', string $cgdNo = '', string $sale_total ="0.00", array $customer = [], array $supplier = [],array &$tempOrder=[])
     {
-        $sale_price = $sale['good_num'] > 0 ? bcdiv($sale_total, $sale['good_num'], 5) : 0;
-        
+        $sale_price = $sale['good_num'] > 0 ? bcdiv($sale_total, $sale['good_num'], 8) : 0;
+
         $origin_total =round($sale['origin_price']*$sale['good_num'],8);
         $tmp_sale = [
         	'manager'=>$sale['manager'],
@@ -242,7 +256,7 @@ class SplitSale extends Command
              'open_type'=>$sale['open_type'],
             'updatetime' => $sale['updatetime'],
             'delivery_day' => $sale['delivery_day'] ?? 0,
-            'th_fee' => round(bcmul($sale_price, $sale['th_num'] ?? 0, 3), 2),
+            'th_fee' => round(bcmul($sale_price, $sale['th_num'] ?? "0", 3), 2),
             'cost_fee' => $sale['cost_price'] ?? 0,
             'diff_fee' => $sale['diff_fee'] ?? 0,
              'tax' => $sale['tax'] ?? '',
@@ -314,7 +328,7 @@ class SplitSale extends Command
 
     //构建采购单
     private function _handle_cgd_caixiao(array $cgd = [], array $sale = [], array $pay_rate = [], string $cgdNo = '',
-     string $orderCode = '', float $cgd_total = 0.00,array &$tempOrder=[])
+     string $orderCode = '', string $cgd_total ="0.00",array &$tempOrder=[])
     {
 
         $good_price = $sale['good_num'] > 0 ? bcdiv($cgd_total, $sale['good_num'], 8) : 0;
@@ -346,7 +360,7 @@ class SplitSale extends Command
             'send_status' => $sale['send_status'] ?? '',
             "open_type"=>$sale['open_type'],
             'th_num' => $sale['th_num'] ?? 0,
-            'th_fee' => round(bcmul($good_price, $sale['th_num'] ?? 0, 3), 2),
+            'th_fee' => round(bcmul($good_price, $sale['th_num'] ?? "0", 8), 2),
             'updatetime' => $sale['updatetime'],
         ];
 

+ 1 - 18
app/command/handleYzOrderData.php

@@ -34,8 +34,8 @@ class handleYzOrderData extends Command
         if($limit==1){
         	return '' ;
         }
-        $c_data = Cache::store('redis')->handler()->rpop(Config::get('app.handle_queue_key'));
         Cache::store('redis')->set("YzTimeLimit",1,60);
+        $c_data = Cache::store('redis')->handler()->rpop(Config::get('app.handle_queue_key'));
         if ($c_data){
 
             $c_data = json_decode($c_data, true);
@@ -436,22 +436,6 @@ class handleYzOrderData extends Command
                         } else throw new Exception('发货地址添加失败');
                     }
                 }
-
-                //复用sale::create()方法 -- end
-
-                //处理完成
-//                $order_import_from_c_db
-//                    ->where('id', $c_data['id'])
-//                    ->where('is_del', OIFCModel::$is_del_normal)
-//                    ->save([
-//                        'status' => $order_import_from_c_db::$status_success,
-//                        'updatetime' => date('Y-m-d H:i:s'),
-//                        'remark' => '',
-//                        'updateid' => 0,
-//                        'updater' => 'system',
-//                        'orderCode' => $orderCode
-//                    ]);
-
                 //维护台账记录
                 Db::name('standing_book')->insert(array_merge($standing_book_data, ['addtime' => date('Y-m-d H:i:s'), 'updatetime' => date('Y-m-d H:i:s'), 'standBookNo' => makeNo("IO")]));
 
@@ -476,7 +460,6 @@ class handleYzOrderData extends Command
                             'addtime' => $this->cgd_data['addtime'],
                         ],
                     ], JSON_UNESCAPED_UNICODE);
-//                    Cache::store("redis")->handler()->lPush(Config::get('app.abutment_queue'), $push_data);
                 }
 
                 Db::commit();