wugg 4 months ago
parent
commit
3f4b1ab2d7

+ 40 - 2
app/admin/controller/Good.php

@@ -4,15 +4,53 @@
 namespace app\admin\controller;
 
 
-use think\App;
+use app\admin\model\GoodBasic;use app\user\model\AccountCompany;use app\user\model\AccountItem;use think\App;
 class Good extends Base{
     public function __construct(App $app)
     {
         parent::__construct($app);
-        $this->model=new \app\admin\model\Good();
+        $this->model=new \app\admin\model\GoodBasic();
     }
 
     public function list(){
+        $params=$this->request->param(['cat_id'=>'','is_combind'=>'','good_name'=>"","spucode"=>"","good_type"=>"",
+        "companyNo"=>"","supplierNo"=>"","supplier"=>"","company"=>"","brandid"=>"","status"=>[],"is_stock"=>"",
+        'start'=>"","end"=>"","isonline"=>"","relaComNo"=>"","page"=>1,"size"=>15]);
+        $where=[["is_del","=",0]];
+        if($params['cat_id']!="")$where[]=["cat_id","=",$params['cat_id']];
+        if($params['is_combind']!="") $where[]=["is_combind","=",$params['is_combind']];
+        if($params['good_name']!="") $where[]=["good_name","like","%".$params['good_name']."%"];
+        if($params['spucode']!="") $where[]=["spuCode","like","%".$params['spucode']."%"];
+        if($params['good_type']!="") $where[]=["good_type","=",$params['good_type']];
+        if($params['companyNo']!="") $where[]=["companyNo","like","%".$params['companyNo']."%"];
+        if($params['supplierNo']!="") $where[]=["supplierNo","like","%".$params['supplierNo']."%"];
+        if($params['supplier']!="") $where[]=["supplierName","like","%".$params['supplier']."%"];
+        if($params['company']!="") $where[]=["companyName","like","%".$params['company']."%"];
+        if($params['brandid']!="") $where[]=["brandid","=",$params['brandid']];
+        if(!empty($params['status'])) $where[]=["status","in",$params['status']];
+        if($params['is_stock']!="") $where[]=["is_stock","=",$params['is_stock']];
+        if($params['isonline']!=""){
+                if($params['isonline']==1) $where[]=["spuCode","in",function ($query) {
+                        $query->name('good_platform')->where('exam_status', 3)->field('spuCode');
+                    }];
+                else $where[]=['spuCode','not in',function ($query) {
+                        $query->name('good_platform')->where('exam_status', 3)->field('spuCode');
+                    }];
+        }
+        if($params['relaComNo']!="") $where[]=["companyNo|supplierNo","like","%".$params['relaComNo']."%"];
+        $list=$this->model->with(["brand","unit","cat","GoodTax"])
+        ->where($where)
+        ->order("id desc")
+        ->paginate(["page"=>$params['page'],"list_rows"=>$params['size']])
+        ->each(function (&$item){
+            $item['exclusive']=\app\admin\model\Exclusive::getExclusive($item['is_exclusive']);
+            $item['noble_name']=GoodBasic::$NobleMetalCn[$item->noble_metal];
+            $item['has_account'] = AccountCompany::SupplierHasAcount($item->supplierNo);
+            $info = AccountItem::with(['ItemName'])->where(['account_id'=>$item->chargerid])->findOrEmpty();
+            $item['charger_company_name'] =  $info->depart_name??"";
+        });
+        return success("获取成功",["list"=>$list->items(),"count"=>$list->total()]);
+
     }
     public function create(){
     }

+ 2 - 1
app/admin/controller/GoodZx.php

@@ -81,6 +81,7 @@ class GoodZx extends Base{
         if($good->isEmpty()) return error("咨询商品不存在");
         $good_tax = GoodTax::where("spuCode","=",$param['spuCode'])->findOrEmpty();
         $good_tax->open_type=$good->open_type;
+         $good_tax->spuCode=$param['spuCode'];
         $good_tax->companyNo = $good->companyNo;
         $good_tax->tax_id = $param['tax_id'];
         $good_tax->tax = $param['tax'];
@@ -89,6 +90,7 @@ class GoodZx extends Base{
         $good_tax->out_tax = $param['out_tax'];
         $good_tax->cgd_tax_id = $param['cgd_tax_id'];
         $good_tax->cgd_tax = $param['cgd_tax'];
+        $good_tax->status=($param['tax_id']>0 && $param['out_tax_id']>0)?2:1;
         $good_tax->createrid=$good_tax->createrid??$this->uid;
         $good_tax->creater=$good_tax->creater??$this->uname;
         $this->model->startTrans();
@@ -99,7 +101,6 @@ class GoodZx extends Base{
                 $sale = \app\admin\model\Sale::where("good_code","=",$param['spuCode'])->findOrEmpty();
                 if(!$sale->isEmpty()){
                     $sale->updatetime=date('Y-m-d H:i:s');
-                    $sale->save();
                     if($sale->save()==false) throw new \Exception('同步销售单失败');
                 }
                 OrderTax::where(["spuCode"=>$param['spuCode'],"code"=>$sale->orderCode])->delete();

+ 0 - 20
app/admin/model/AbutmentRequestLog.php

@@ -1,20 +0,0 @@
-<?php
-namespace app\admin\model;
-
-class AbutmentRequestLog extends Base
-{
-//设置字段信息
-    protected $schema = [
-        'id'       =>'int',//
-        'request_id'       =>'char',//请求唯一标识
-        'ipaddr'       =>'varchar',//请求方的ip地址
-        'action'       =>'varchar',//请求接口地址
-        'param'       =>'longtext',//请求参数
-        'response'       =>'text',//响应内容
-        'supplierNo'       =>'varchar',//供应商编码
-        'uid'       =>'int',//操作人id
-        'addtime'       =>'datetime',//创建时间
-        'updatetime'       =>'datetime',//修改时间
-
-    ];
-}

+ 8 - 1
app/admin/model/Exclusive.php

@@ -16,6 +16,13 @@ class Exclusive extends Base
         'is_del'       =>'tinyint',//状态
         'addtime'       =>'datetime',//
         'updatetime'       =>'datetime',//
-
     ];
+    public function getExclusive($id,$field=[]){
+        $item = $this->field("id,name,pid")->find($id);
+        array_unshift($field,$item);
+        if($item['pid']>0){
+            $this->getExclusive($item['pid'],$field);
+        }
+        return $field;
+    }
 }

+ 6 - 1
app/admin/model/GoodBasic.php

@@ -87,13 +87,18 @@ class GoodBasic extends Base
         return $this->hasOne('Unit','good_unit','id')->bind(["unit_name"]);
     }
     public function Cat(){
-        return $this->hasOne('Cat','cat_id','id')->bind(["cat_name"]);
+        return $this->hasOne('Cat','cat_id','id')->bind(["cat_name","search"]);
     }
 
     public function Brand(){
         return $this->hasOne('Brand','brand_id','id')->bind(["brand_name"]);
     }
 
+    public function getIsOnlineAttr($value,$data){
+           $iT= GoodPlatform::where(["spuCode"=>$data['spuCode'],"exam_status"=>3,"is_del"=>0])->findOrEmpty()->isEmpty();
+        return $iT?0:1;
+    }
+
     public function GoodTax(){
         return $this->hasOne('GoodTax',"spuCode",'spuCode')
         ->bind([

+ 13 - 10
app/cxinv/controller/Trade.php

@@ -27,7 +27,7 @@ class Trade extends Base{
             "sequenceNo|关联订单编号"=>"require|max:255",
             "trad_fee|关联订单金额"=>"require|float|min:0.01"]);
         $assoc=[];
-        $log_total = 0;
+        $log_total = "0";
         $logInfo=[];
         $qrdList = QrdInfo::where('sequenceNo','in',array_column($params['orderArr'],'sequenceNo'))
         ->column("id,sequenceNo,platform_type,wpay_fee,pay_fee,is_comon,pay_status,totalPrice,customerNo","sequenceNo");
@@ -36,8 +36,8 @@ class Trade extends Base{
             if(!isset($qrdList[$order['sequenceNo']])) return error("关联订单信息不存在");
             if($qrdList[$order['sequenceNo']]['wpay_fee']<$order['trad_fee']) return error("销售单{$order['sequenceNo']}未付款金额不足核销金额");
             //if($qrdList[$order['sequenceNo']]['is_comon']==1) return error("{$order['sequenceNo']} 通用订单不可认领资金");
-            $qrdList[$order['sequenceNo']]['wpay_fee']-=$order['trad_fee'];
-            $log_total+=$order['trad_fee'];
+            $qrdList[$order['sequenceNo']]['wpay_fee']=bcsub($qrdList[$order['sequenceNo']]['wpay_fee'],$order['trad_fee'],2) ;
+            $log_total=bcadd($log_total,$order['trad_fee'],2);
            $temp=[
                'logNo'=>makeNo("TRC",str_pad($key+1,4,'0',STR_PAD_LEFT)),
                 'tradNo'=>$params['tradNo'],
@@ -556,11 +556,14 @@ class Trade extends Base{
              if(!isset($orderArr[$value['orderCode']])) return error($value['orderCode'].'订单信息不存在');
              if($orderArr[$value['orderCode']]['companyNo']!=$value['companyNo']) return error($value['orderCode'].'卖出方公司与订单业务公司不一致');
              if($orderArr[$value['orderCode']]['wpay_fee']< $value['trad_fee']) return error($value['orderCode'].'销售单未付款金额不足核销金额');
-             $orderArr[$value['orderCode']]['wpay_fee']-=$value['trad_fee'];
+             $orderArr[$value['orderCode']]['wpay_fee']=bcsub($orderArr[$value['orderCode']]['wpay_fee'], $value['trad_fee'],2);
              if(!isset($tradeArr[$value['tradNo']])) return error($value['tradNo'].'资金流水信息不存在');
              if($tradeArr[$value['tradNo']]['trade_type']!=1 && $orderArr[$value['orderCode']]['is_comon']==1) return error($value['orderCode'].'销售单类型与资金类型不匹配');
-             if($tradeArr[$value['tradNo']]['balance']< $value['trad_fee']) return error($value['tradNo'].'资金流水余额不足核销金额');
-             $tradeArr[$value['tradNo']]['balance']-=$value['trad_fee'];
+
+             if($tradeArr[$value['tradNo']]['balance']< $value['trad_fee']){
+                 return error($value['tradNo'].'资金流水余额不足核销金额');
+             }
+             $tradeArr[$value['tradNo']]['balance']=bcsub($tradeArr[$value['tradNo']]['balance'], $value['trad_fee'],2);
              if($tradeArr[$value['tradNo']]['companyNo']!=$value['companyNo']) return error($value['tradNo'].'资金流水业务公司与卖出方公司不一致');
              $temp=['logNo' => makeNo('TRC',str_pad($key+1,4,'0',STR_PAD_LEFT)),
                      'tradNo' => $value['tradNo'],
@@ -598,8 +601,8 @@ class Trade extends Base{
                                  ->findOrEmpty();
                  if($trade->isEmpty()) throw new \Exception($value['tradNo'].'资金流水信息不存在');
                  if($trade->balance< $value['trad_fee']) throw new \Exception($value['tradNo'].'资金流水余额不足核销金额');
-                 $trade->balance-=$value['trad_fee'];
-                 $trade->used_fee+=$value['trad_fee'];
+                 $trade->balance=bcsub($trade->balance, $value['trad_fee'],2);
+                 $trade->used_fee=bcadd($trade->used_fee, $value['trad_fee'],2);
                  $trade->status=$trade->balance==0?3:2;
                  $tradSave=$trade->save();
                  if(!$tradSave) throw new \Exception($value['tradNo'].'资金流水更新失败');
@@ -609,8 +612,8 @@ class Trade extends Base{
                              ->findOrEmpty();
                  if($order->isEmpty()) throw new \Exception($value['orderCode'].'订单信息不存在');
                  if($order->wpay_fee< $value['trad_fee']) throw new \Exception($value['orderCode'].'销售单未付款金额不足核销金额');
-                 $order->wpay_fee-=$value['trad_fee'];
-                 $order->apay_fee+=$value['trad_fee'];
+                 $order->wpay_fee=bcsub($order->wpay_fee, $value['trad_fee'],2);
+                 $order->apay_fee=bcadd( $order->apay_fee, $value['trad_fee'],2);
                  $order->pay_status=$order->wpay_fee==0 && $order->pay_fee==0?3:2;
                  $order->status=1;
                  $ordersave=$order->save();