Эх сурвалжийг харах

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

wugg 2 жил өмнө
parent
commit
5c32c505a3

+ 190 - 0
app/admin/controller/Pay.php

@@ -0,0 +1,190 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\admin\controller;
+
+use think\App;
+use think\Error;use think\Exception;use think\facade\Validate;
+use think\Request;
+use think\facade\Db;
+class Pay extends Base
+{
+	public function __construct(App $app) {
+		parent::__construct($app);
+	}
+    /**
+     * 显示资源列表
+     */
+    public function list()
+    {
+    	$param =$this->request->param(["pay_name"=>"","page"=>1,"size"=>10],"post","tirm");
+    	$where=[];
+    	if($param['pay_name']!='') $where[]=["pay_name","like","%{$param['pay_name']}%"];
+    	$count =Db::name("pay")->where($where)->count();
+    	$total =ceil($count/$param['size']);
+    	$page = $total>=$param['page']? intval($param['page']) : intval($total);
+    	$list =Db::name("pay")->where($where)->page($page,intval($param['size']))->order("id desc")->select();
+    	return app_show(0,"获取成功",["list"=>$list,'count'=>$count]);
+    }
+
+    /**pay_rate 数据
+     * ['companyNo'=>'GYS','companyName'=>'供应商']
+     * [] 业务公司+销售平台
+     * ['companyNo'=>'KH','companyName'=>'客户']
+     *
+     * @return \think\Response
+     */
+    public function create()
+    {
+    	$param = $this->request->only(["pay_name"=>"","pay_rate"=>[]],"post");
+    	$valid = Validate::rule([
+    		"pay_name|名称"=>"require|max:255|min:2",
+    		"pay_rate|内容"=>"require|array",
+    	]);
+    	if($valid->check($param)==false) return error_show(1004,$valid->getError());
+    	$isT =Db::name("pay")->where("pay_name",$param['pay_name'])->findOrEmpty();
+    	if(!empty($isT)) return error_show(1004,"名称已存在");
+    	Db::startTrans();
+    	try{
+			$data=[
+				"pay_name"=>$param['pay_name'],
+				"apply_id"=>$this->uid,
+				"apply_name"=>$this->uname,
+				"status"=>1
+			];
+			$payadd =Db::name("pay")->insertGetId($data);
+			if($payadd==false) throw new Exception('新建失败');
+			$payinfo=[];
+			foreach ($param['pay_rate'] as $key=>$item){
+				$temp=[];
+				$temp['pay_id'] = $payadd;
+				$temp['companyNo'] = $item['companyNo'];
+				$temp['companyName'] = $item['companyName'];
+				$temp['rate'] = $item['rate']??0;
+				$temp['is_cgd'] = $item['is_cgd']??0;
+				$temp['is_qrd'] = $item['is_qrd']??0;
+				$temp['weight'] = $key;
+				$temp['status'] = 1;
+				$payinfo[]=$temp;
+			}
+			$payin = Db::name("pay_rate")->insertAll($payinfo);
+			if($payin==false) throw new Exception('新建失败');
+			Db::commit();
+			return app_show(0,"新建成功");
+    	}catch (\Exception $e){
+			Db::rollback();
+			return error_show(1005,$e->getMessage());
+    	}
+    }
+
+    /**
+     * 保存新建的资
+     */
+    public function save()
+    {
+        	$param = $this->request->only(["id"=>"","pay_name"=>"","pay_rate"=>[]],"post");
+    	$valid = Validate::rule([
+    		"pay_name|名称"=>"require|max:255|min:2",
+    		"pay_rate|内容"=>"require|array",
+    		"id|主键ID"=>"require|number",
+    	]);
+    	if($valid->check($param)==false) return error_show(1004,$valid->getError());
+    	$isT =Db::name("pay")->where("id",$param['id'])->findOrEmpty();
+    	if(empty($isT)) return error_show(1004,"未找到数据");
+    	$isT =Db::name("pay")->where([["id","<>",$param['id']],["pay_name","=",$param['pay_name']]])->findOrEmpty();
+    	if(!empty($isT)) return error_show(1004,"名称已存在");
+    	Db::startTrans();
+    	try{
+			$data=[
+				"id"=>$param['id'],
+				"pay_name"=>$param['pay_name'],
+				"updatetime"=>date("Y-m-d H:i:s")
+			];
+			$payadd =Db::name("pay")->save($data);
+			if($payadd==false) throw new Exception('更新失败');
+			foreach ($param['pay_rate'] as $key=>$item){
+				$temp=[];
+				$temp['pay_id'] = $param['id'];
+				$temp['id'] = $item['id']??null;
+				$temp['companyNo'] = $item['companyNo'];
+				$temp['companyName'] = $item['companyName'];
+				$temp['rate'] = $item['rate']??0;
+				$temp['is_cgd'] = $item['is_cgd']??0;
+				$temp['is_qrd'] = $item['is_qrd']??0;
+				$temp['weight'] = $key;
+				$temp['status'] = $item['status']??1;
+				$temp['is_del'] =$item['is_del']??0;
+				$payin = Db::name("pay_rate")->save($temp);
+				if($payin==false) throw new Exception('更新失败');
+			}
+			Db::commit();
+			return app_show(0,"更新成功");
+    	}catch (\Exception $e){
+			Db::rollback();
+			return error_show(1005,$e->getMessage());
+    	}
+    }
+
+    /**
+     * 显示指定的资源
+     *
+     */
+    public function info()
+    {
+		$param =$this->request->only(["id"=>''],"post","trim");
+		$valid= Validate::rule(["id|主键ID"=>"require|number" ]);
+		if($valid->check($param)==false) return error_show(1004,$valid->getError());
+		$isT =Db::name("pay")->where("id",$param['id'])->findOrEmpty();
+    	if(empty($isT)) return error_show(1004,"未找到数据");
+    	$info =Db::name("pay_rate")->where(["pay_id"=>$param['id'],"is_del"=>0])->order("weight asc,id desc")->select()
+    	->toArray();
+    	$isT["pay_rate"] = $info;
+    	return app_show(0,"获取成功",$isT);
+    }
+
+    /**
+     * 显示编辑资源表单页.
+     *
+     * @param  int  $id
+     * @return \think\Response
+     */
+    public function status()
+    {
+        $param =$this->request->only(["id"=>'',"status"=>""],"post","trim");
+		$valid= Validate::rule([
+			"id|主键ID"=>"require|number",
+			"status|状态"=>"require|number|in:0,1",
+			]);
+		if($valid->check($param)==false) return error_show(1004,$valid->getError());
+		$isT =Db::name("pay")->where("id",$param['id'])->findOrEmpty();
+    	if(empty($isT)) return error_show(1004,"未找到数据");
+    	if($isT['status']==$param['status']) return error_show(1004,"状态已更新");
+    	$isT['status'] = $param['status'];
+    	$isT['updatetime'] =date("Y-m-d H:i:s");
+    	$upT =Db::name("pay")->save($isT);
+    	return $upT? app_show(0,"状态更新成功"):error_show(1004,"状态更新失败");
+    }
+
+    /**
+     * 保存更新的资源
+     *
+     * @param  \think\Request  $request
+     * @param  int  $id
+     * @return \think\Response
+     */
+    public function update(Request $request, $id)
+    {
+        //
+    }
+
+    /**
+     * 删除指定资源
+     *
+     * @param  int  $id
+     * @return \think\Response
+     */
+    public function delete($id)
+    {
+        //
+    }
+}

+ 6 - 19
app/admin/controller/Sale.php

@@ -50,6 +50,12 @@ class Sale extends Base
         }
         $goodtype = isset($this->post['goodtype']) && $this->post['goodtype'] !== "" ? intval($this->post['goodtype']) : "1";
         $order_type = isset($this->post['order_type']) && $this->post['order_type'] !== "" ? intval($this->post['order_type']) : "1";
+        $pay_id = isset($this->post['pay_id']) && $this->post['pay_id'] !== "" ? intval($this->post['pay_id']) : "0";
+        if($pay_id!=0){
+        	$payinfo =Db::name("pay")->where("id",$pay_id)->findOrEmpty();
+        	if(empty($payinfo)) return error_show(1004, "付款流程信息未找到");
+        	if($payinfo['status']!=1)return error_show(1004, "付款流程信息已禁用");
+        }
         $sendtype = isset($this->post['sendtype']) && $this->post['sendtype'] !== "" ? intval($this->post['sendtype']) : "";
         if ($sendtype === '') {
             return error_show(1004, "参数sendtype不能为空");
@@ -73,7 +79,6 @@ class Sale extends Base
         }
         $paytime = isset($this->post['paytime']) && $this->post['paytime'] != "" ? $this->post['paytime'] : "";
         $workNo = isset($this->post['workNo']) && $this->post['workNo'] != "" ? trim($this->post['workNo']) : "";
-        // $poNo =isset($this->post['poNo'])&&$this->post['poNo']!=""? trim($this->post['poNo']):"";
         $ct = Db::name('good_platform')->alias('a')->join('good b', 'b.spuCode=a.spuCode', 'left')
             ->where(['a.skuCode' => $good_code])->field("b.*,a.skuCode,a.platform_code,a.plat_code")->find();
         if ($ct == false) {
@@ -1572,24 +1577,6 @@ class Sale extends Base
         if ($goodinfo == false) {
             return false;
         }
-//            $cat_top_list = made($goodinfo['cat_id']);
-//            $cat_top_id = isset($cat_top_list[0]['id']) ? $cat_top_list[0]['id'] : 0;
-////            $saleprice = $goodinfo['sale_price'];
-//            if ($goodinfo['is_gold_price'] == 1 && $cat_top_id == 6) {
-//                $gold = Db::name("gold_price1")
-//                    ->field('id,price')
-//                    ->where(["type" => $goodinfo['metal_id'], "is_del" => 0, "status" => 1])
-//                    ->order("addtime desc")
-//                    ->find();
-//                 $goodinfo['gold_price'] = $gold["price"];
-//                $data['sale_price'] = $goodinfo['demo_fee'] /$data['good_num'] + $goodinfo['open_fee'] / $data['good_num'] +
-//                $goodinfo['good_weight'] * $gold["price"] + $goodinfo['cost_fee'] * $goodinfo['good_weight'] +
-//                $goodinfo['pakge_fee'] + $goodinfo['mark_fee'] + $goodinfo['cert_fee'] + $goodinfo['nake_fee'] + $goodinfo['delivery_fee'];
-////                 if($data['sale_price']< $saleprice){
-////            	        return false;
-////                }
-//			}
-
         $orderCode = makeNo("QR");
         $supplier_temp_info = Db::name('supplier')
             ->field('id,person,personid')

+ 7 - 5
app/admin/route/app.php

@@ -394,7 +394,6 @@ Route::rule('goodofflist', 'admin/GoodOfflineLog/getList');
 Route::rule('goodoffdetail', 'admin/GoodOfflineLog/getDetail');
 
 Route::rule('goodproof', 'admin/Goodup/prooflist');
-
 Route::rule('activitylist', 'admin/Activity/list');
 Route::rule('activitylinst', 'admin/Activity/linst');
 Route::rule("zixunlist", 'admin/Activity/zilist');
@@ -433,7 +432,6 @@ Route::rule('titledelete', 'admin/Title/del');
 Route::rule('titlestatus', 'admin/Title/status');
 
 Route::rule('ocrquery', 'admin/Ocrlicense/query');
-
 Route::rule('consultlists', 'admin/Consult/conlist');
 Route::rule('consultinfo', 'admin/Consult/info');
 Route::rule('consultdel', 'admin/Consult/del');
@@ -606,7 +604,6 @@ Route::rule('pome', 'admin/SaleReport/purcheaseOrderMonthExport');//十三、供
 Route::rule('popm', 'admin/SaleReport/purcheaseOrderPersonMonth');//十四、供应商负责人采购订单情况
 Route::rule('popme', 'admin/SaleReport/purcheaseOrderPersonMonthExport');//十四、供应商负责人采购订单情况-导出
 
-
 Route::rule("catplatadd", "admin/CatPlat/add");
 Route::rule("catplatedit", "admin/CatPlat/edit");
 Route::rule("catplatlist", "admin/CatPlat/list");
@@ -619,10 +616,8 @@ Route::rule('statlist', 'admin/Stat/list');//
 Route::rule('salereport', 'admin/Stat/saleReport');//
 Route::rule('bkreport', 'admin/Stat/bkReport');//
 
-
 Route::rule('standbooklist', 'admin/StandingBook/getList');//台账列表
 Route::rule('standbookdetail', 'admin/StandingBook/getDetail');//台账详情
-
 route::rule('getAccountList', 'admin/Account/getAccountList');//获取供应商账号列表
 route::rule('changePassword', 'admin/Account/changePassword');//修改供应商账号密码
 route::rule('readAccount', 'admin/Account/readAccount');//获取供应商账号账号信息
@@ -651,3 +646,10 @@ route::rule('statusDataShare', 'admin/DataShare/statusDataShare');//启/禁用
 route::rule('filingList', 'admin/Filing/getList');//列表
 route::rule('filingDetail', 'admin/Filing/detail');//详情
 route::rule('filingStatus', 'admin/Filing/status');//审核
+
+
+route::rule("payadd","admin/Pay/create");//支付渠道新建
+route::rule("payedit","admin/Pay/save");//支付渠道编辑
+route::rule("paylist","admin/Pay/list");//支付渠道列表
+route::rule("payinfo","admin/Pay/info");//支付渠道新建
+route::rule("paystatus","admin/Pay/status");//支付渠道新建