Browse Source

Merge branch 'version1.5' of wugg/phpstock into master-online

wugg 2 years ago
parent
commit
a387cae506

+ 18 - 8
app/admin/controller/Consult.php

@@ -1784,15 +1784,25 @@ class Consult extends Base
                     ->find();
             }
             //产地
-            if($value['origin_place']!=''){
-                $code = explode(",",$value['origin_place']);
-                $temp=[];
-                $temp['provice_code']=isset($code[0])?$code[0]:"";
-                $temp['city_code']=isset($code[1])?$code[1]:"";
-                $temp['area_code']=isset($code[2])?$code[2]:"";
-                $addr= GetAddr(json_encode($temp));
-                $value['origin_addr'] = $addr;
+            $place = ["provice_code"=>"","city_code"=>"","area_code"=>""];
+            if($value['delivery_place']!=""){
+                list($place['provice_code'],$place['city_code'],$place['area_code'])=explode(",",$value['delivery_place']);
             }
+            $value['delivery_place_cn']=GetAddr(json_encode($place));
+            $place = ["provice_code"=>"","city_code"=>"","area_code"=>""];
+            if($value['origin_place']!=""){
+                list($place['provice_code'],$place['city_code'],$place['area_code'])=explode(",",$value['origin_place']);
+            }
+            $value['origin_addr']=GetAddr(json_encode($place));
+//            if($value['origin_place']!=''){
+//                $code = explode(",",$value['origin_place']);
+//                $temp=[];
+//                $temp['provice_code']=isset($code[0])?$code[0]:"";
+//                $temp['city_code']=isset($code[1])?$code[1]:"";
+//                $temp['area_code']=isset($code[2])?$code[2]:"";
+//                $addr= GetAddr(json_encode($temp));
+//                $value['origin_addr'] = $addr;
+//            }
             $data[] = $value;
         }
         return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);

+ 24 - 9
app/admin/controller/Data.php

@@ -15,19 +15,34 @@ class Data extends Base
         $data = [];
 
         //1.今日销量(单数、金额)
+        $today_sales_volume = Db::name('sale')
+            ->field('count(id) orders_number,sum(total_price) money')
+            ->where('is_del',0)
+            ->whereDay('addtime','today')
+            ->find();
+
         $data['today_sales_volume'] = [
-            'orders_number' => '0',
-            'money' => '00.00'
+            'orders_number' => isset($today_sales_volume['orders_number'])?$today_sales_volume['orders_number']:0,
+            'money' =>  isset($today_sales_volume['money'])?$today_sales_volume['money']:0,
         ];
 
         //2.今日销冠(部门、姓名、单数、金额)
-        $data['today_sales_champion'] = [
-            'company_id' => '0',
-            'company' => 'xxx部',
-            'nickname' => '张三',
-            'orders' => '0',
-            'money' => '00.00'
-        ];
+        $temp = Db::name('sale')
+            ->field('count(id) orders,sum(total_price) money,apply_id')
+            ->where('is_del',0)
+            ->whereDay('addtime','today')
+            ->group('apply_id')
+            ->order('money','desc')
+            ->limit(1)
+            ->buildSql();
+
+        $data['today_sales_champion'] = Db::table($temp)
+            ->alias('t')
+            ->field('t.apply_id,t.orders,t.money,u.itemid company_id,	c.`name` company,	u.nickname')
+            ->leftJoin('depart_user u','u.uid=t.apply_id AND u.is_del=0')
+            ->leftJoin('company_item c','c.id=u.itemid AND c.is_del=0')
+            ->select()
+            ->toArray();
 
         //3.今日采购(采购订单数量、商品数量、竞价单数、反馈商品数)
         $data['today_purchase'] = [

+ 43 - 26
app/admin/controller/Purch.php

@@ -405,36 +405,53 @@ class Purch extends Base
         }
     }
 
-    public function status(){
-        $cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo']!="" ?trim($this->post['cgdNo']):"";
+    public function status()
+    {
+        $cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo'] != "" ? $this->post['cgdNo'] : [];
 
-        if($cgdNo==""){
-            return error_show(1004,"参数cgdNo 不能为空");
-        }
-        $data = Db::name("purchease_order")->where(["cgdNo"=>$cgdNo,"is_del"=>0])->find();
-        if(empty($data)){
-            return error_show(1004,"未找到数据");
+        if (empty($cgdNo)) {
+            return error_show(1004, "参数cgdNo 不能为空");
         }
-        $remark= isset($this->post['remark']) && $this->post['remark']!="" ?trim($this->post['remark']):"";
-        $status = isset($this->post['status'])&&$this->post['status']!==""? intval($this->post['status']):"";
-        if($status===""){
-            return error_show(1004,"参数status 不能为空");
+
+        $remark = isset($this->post['remark']) && $this->post['remark'] != "" ? trim($this->post['remark']) : "";
+        $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
+        if ($status === "") {
+            return error_show(1004, "参数status 不能为空");
         }
-        if($data['send_status']>1 && $status==0){
-            return error_show(1004,"采购单发货中无法取消");
+
+        if ($status == 0) {
+            $data = Db::name("purchease_order")
+                ->field('id,cgdNo')
+                ->whereIn('cgdNo', $cgdNo)
+                ->where(["is_del" => 0])
+                ->where('send_status', '>', 1)
+                ->find();
+            if (!empty($data)) {
+                return error_show(1004, $data['cgdNo'] . "采购单发货中无法取消");
+            }
         }
-        $order = ["order_code"=>$cgdNo,"status"=> $data['status'] ,"action_remark"=>$remark,"action_type"=>"status"];
-        $data['status'] = $status;
-        $data['remark'] = $remark;
-        $data['updatetime'] =date("Y-m-d H:i:s");
-        $upd=Db::name("purchease_order")->save($data);
-        if($upd){
-            $process=["order_code"=>$cgdNo,"order_id"=>$data['id'],"order_status"=>$status,"order_type"=>'CGD'];
-            ProcessOrder::AddProcess($this->post['token'],$process);
-            ActionLog::logAdd($this->post['token'],$order,'CGD',$status,$this->post);
-            return app_show(0,"更新成功");
-        }else{
-            return error_show(1004,'更新失败');
+//        if($data['send_status']>1 && $status==0){
+//            return error_show(1004,"采购单发货中无法取消");
+//        }
+//        $order = ["order_code"=>$cgdNo,"status"=> $data['status'] ,"action_remark"=>$remark,"action_type"=>"status"];
+//        $data['status'] = $status;
+//        $data['remark'] = $remark;
+//        $data['updatetime'] =date("Y-m-d H:i:s");
+        $upd = Db::name("purchease_order")
+            ->whereIn('cgdNo', $cgdNo)
+            ->save([
+                'status' => $status,
+                'remark' => $remark,
+                'updatetime' => date("Y-m-d H:i:s"),
+            ]);
+        if ($upd) {
+            $process = ["order_code" => implode(',', $cgdNo), "order_id" => 0, "order_status" => $status, "order_type" => 'CGD'];
+            ProcessOrder::AddProcess($this->post['token'], $process);
+            $order = ["order_code" => implode(',', $cgdNo), "status" => '', "action_remark" => $remark, "action_type" => "status"];
+            ActionLog::logAdd($this->post['token'], $order, 'CGD', $status, $this->post);
+            return app_show(0, "更新成功");
+        } else {
+            return error_show(1004, '更新失败');
         }
     }
     public function diffcreat(){

+ 53 - 3
app/command/ImportOrderFromCHandleData.php

@@ -522,15 +522,65 @@ class ImportOrderFromCHandleData extends Command
 
         if ($cgd == false) return false;
 
-        $cgd['balance_num'] -= $outinfo['good_num'];
-        $cgd['merge_num'] += $outinfo['good_num'];
+        $cgdinfo = Db::name("purchease_order")
+            ->where(['cgdNo' => $cgd['cgdNo'], "is_del" => 0])
+            ->find();
+        if ($cgdinfo == false) return false;
+
+        $QrdCgd = [
+            "cgdNo" => makeNo("CG"),
+            "bkcode" => $cgdinfo['bkcode'],
+            'wsm_code' => $cgdinfo['wsm_code'],
+            "cgder_id" => $cgdinfo['cgder_id'],
+            "cgder" => $cgdinfo['cgder'],
+            "spuCode" => $cgdinfo['spuCode'],
+            "good_name" => $cgdinfo['good_name'],
+            "good_num" => $cgdinfo['good_num'],
+            "good_price" => $cgdinfo['good_price'],
+            "total_fee" => round($cgdinfo['good_price'] * $outinfo['good_num'], 2),
+            "pakge_fee" => $cgdinfo['pakge_fee'],
+            "cert_fee" => $cgdinfo['cert_fee'],
+            "open_fee" => $cgdinfo['open_fee'],
+            "delivery_fee" => $cgdinfo['delivery_fee'],
+            "mark_fee" => $cgdinfo['mark_fee'],
+            "teach_fee" => $cgdinfo['teach_fee'],
+            "nake_fee" => $cgdinfo['nake_fee'],
+            "demo_fee" => $cgdinfo['demo_fee'],
+            "weight" => $cgdinfo['weight'],
+            "diff_weight" => $cgdinfo['diff_weight'],
+            "diff_fee" => $cgdinfo['diff_fee'],
+            "gold_price" => $cgdinfo['gold_price'],
+            "supplierNo" => $cgdinfo['supplierNo'],
+            "supplier_name" => $cgdinfo['supplier_name'],
+            "companyNo" => $cgdinfo['companyNo'],
+            "send_status" => 3,
+            "send_num" => $outinfo['good_num'],
+            "wsend_num" => 0,
+            "remark" => $cgdinfo['remark'],
+            "status" => 3,
+            "lasttime" => $cgdinfo['lasttime'],
+            "is_del" => 0,
+            "order_type" => 5,
+            "good_type" => $cgdinfo['good_type'],
+            "addtime" => date("Y-m-d H:i:s"),
+            "updatetime" => date("Y-m-d H:i:s")
+        ];
+        $insetrCgd = Db::name("purchease_order")->insert($QrdCgd);
+        if ($insetrCgd == false) return false;
+
+        $merge_num = Db::name("purchease_order")
+            ->where(["bkcode" => $cgdinfo['bkcode'], "order_type" => 5, "is_del" => 0])
+            ->field("sum(send_num)-sum(th_num) as num")
+            ->find();
+        $cgd['balance_num'] = $cgd['total_num'] - $merge_num['num'];
+        $cgd['merge_num'] = $merge_num['num'];
         $cgd['updatetime'] = date("Y-m-d H:i:s");
         $up = Db::name("order_bk")->save($cgd);
         if ($up == false) return false;
 
         $data = [
             "orderCode" => $outinfo['orderCode'],
-            "cgdNo" => $cgd['cgdNo'],
+            "cgdNo" => $QrdCgd['cgdNo'],
             "spuCode" => $outinfo['spuCode'],
             "companyNo" => $outinfo['companyNo'],
             "good_num" => $outinfo['good_num'],