123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740 |
- <?php
- declare (strict_types = 1);
- namespace app\Admin\controller;
- use app\BaseController;
- use think\facade\Db;
- class Inter extends BaseController
- {
- /**
- * 显示资源列表
- *
- * @return \think\Response
- */
- public function list()
- {
- $post = $this->request->post();
- $condition = [['suppitem', '=', '网络部']];
- $page = isset($post['page']) && $post['page'] !== '' ? intval($post['page']) : 1;
- $size = isset($post['size']) && $post['size'] !== '' ? intval($post['size']) : 10;
- $qrdNo = isset($post['qrdNo'])&&$post['qrdNo']!=='' ? trim($post['qrdNo']) :'';
- if($qrdNo!=""){
- $condition[]=['a.qrdNo','=',$qrdNo];
- }
- $cgdNo = isset($post['cgdNo'])&&$post['cgdNo']!=='' ? trim($post['cgdNo']) :'';
- if($cgdNo!=""){
- $condition[]=['a.cgdNo','=',$cgdNo];
- }
- $khNo = isset($post['khNo'])&&$post['khNo']!=='' ? trim($post['khNo']) :'';
- if($khNo!=""){
- $condition[]=['a.companyNo','=',$khNo];
- }
- $supplierNo = isset($post['supplierNo'])&&$post['supplierNo']!=='' ? trim($post['supplierNo']) :'';
- if($supplierNo!=""){
- $condition[]=['a.supplierNo','=',$supplierNo];
- }
- $starttime = isset($post['starttime']) && $post['starttime']!='' ? $post['starttime'] :"";
- if($starttime!=""){
- $condition[]=['a.ordertime','>=',$starttime];
- }
- $endtime = isset($post['endtime']) && $post['endtime']!='' ? $post['endtime'] :"";
- if($endtime!=""){
- $condition[]=['a.ordertime','<=',$endtime];
- }
- $sale_name = isset($post['sale_name']) && $post['sale_name']!='' ? trim($post['sale_name']) :"";
- if($sale_name!=""){
- $condition[]=['a.sale_name','like','%'.$sale_name.'%'];
- }
- $cgd_saler = isset($post['cgd_saler']) && $post['cgd_saler']!='' ? trim($post['cgd_saler']) :"";
- if($cgd_saler!=""){
- $condition[]=['a.cgd_saler','like','%'.$cgd_saler.'%'];
- }
- $count = Db::table('source_all')->alias('a')->join('cfp_qrd_info b','a.productNo=b.sequenceNo','left')
- ->join('cfp_cgd_info c','a.cgdNo=c.ShortText1618315935182','left')->where($condition)->count();
- $total = ceil($count/$size)>1 ? ceil($count/$size) : 1;
- $page = $page>=$total?intval($total):$page;
- $list=Db::table('source_all')->alias('a')->join('cfp_qrd_info b','a.productNo=b.sequenceNo','left')
- ->join('cfp_cgd_info c','a.cgdNo=c.ShortText1618315935182','left')->where($condition)
- ->page(intval($page),$size)->order("a.ordertime desc")->field('a.id,a.productNo,a.companyName as khName,a.companyNo as khNo,a.qrdNo,
- a.supperinfo,a.suppitem,a.poNo,a.ordertime,a.sale_name,a.depart,a.product_name,a.tax,a.sale_price,a.order_num,
- a.sale_total,a.supplier,a.supplierNo,b.Number1618249146997 as apay_fee,b.number1618249149738 as wpay_fee,
- b.Number1618249202608 as ainv_fee,b.Number1618249205231 as winv_fee,a.qrd_type,a.rate*100 as cgd_tax,a.cat_f,
- a.cgdNo, a.workNo as sequenceNo')->select();
- $all =[];
- foreach ($list as $key=>$value){
- if($value['supperinfo']!=''){
- $company = Db::name('company_info')->where('company_name',"=",$value['supperinfo'])->find();
- $value['companyNo'] = isset($company['companyNo']) ? $company['companyNo']:"";
- }else{
- $value['companyNo'] = "";
- }
- $all[]=$value;
- }
- return app_show(0, '获取数据成功', ['list' => $all, 'count' => $count]);
- }
- /**
- * 显示创建资源表单页.
- *
- * @return \think\Response
- */
- public function add()
- {
- $post = $this->request->post();
- $token = isset($post['token']) ? trim($post['token']) : "";
- if ($token == "") {
- return error_show(101, 'token不能为空');
- }
- $effetc = VerifyTokens($token);
- if (!empty($effetc) && $effetc['code'] != 0) {
- return error_show($effetc['code'], $effetc['message']);
- }
- $guserinfo = GetUserInfo($token);
- if (isset($guserinfo['code']) && $guserinfo['code'] != 0) {
- return error_show($guserinfo['code'], $guserinfo['message']);
- }
- $sale_name = isset($post['sale_name']) && $post['sale_name'] != '' ? trim($post['sale_name']) : '';
- if ($sale_name == '') {
- return error_show(1004, "参数sale_name 不能为空");
- }
- $department = isset($post['department']) && $post['department'] != '' ? trim($post['department']) : '网络部';
- $companyNo = isset($post['companyNo']) && $post['companyNo'] != '' ? trim($post['companyNo']) : '';
- if ($companyNo == '') {
- return error_show(1004, "参数companyNo 不能为空");
- }
- $poNo = isset($post['poNo']) && $post['poNo'] != '' ? trim($post['poNo']) : '';
- if ($poNo == '') {
- return error_show(1004, "参数poNo 不能为空");
- }
- $sequenceNo = isset($post['sequenceNo']) && $post['sequenceNo'] != '' ? trim($post['sequenceNo']) : '';
- if ($sequenceNo == '') {
- return error_show(1004, "参数sequenceNo 不能为空");
- }
- $khNo = isset($post['khNo']) && $post['khNo'] != '' ? trim($post['khNo']) : '';
- if ($khNo == '') {
- return error_show(1004, "参数khNo 不能为空");
- }
- $cunstmer = Db::name('customer_info')->where('companyNo', "=", $khNo)->find();
- if (empty($cunstmer)) {
- return error_show(1004, "客户信息未找到");
- }
- $qrdType = isset($post['qrdType']) && $post['qrdType'] != '' ? trim($post['qrdType']) : '';
- if ($qrdType == '') {
- return error_show(1004, "参数qrdType 不能为空");
- }
- $goodName = isset($post['goodName']) && $post['goodName'] != '' ? trim($post['goodName']) : '';
- if ($goodName == '') {
- return error_show(1004, "参数goodName 不能为空");
- }
- $tax = isset($post['tax']) && $post['tax'] != '' ? trim($post['tax']) : '';
- if ($tax == '') {
- return error_show(1004, "参数tax 不能为空");
- }
- $goodNum = isset($post['goodNum']) && $post['goodNum'] !== '' ? intval($post['goodNum']) : '';
- if ($goodNum === '') {
- return error_show(1004, "参数goodNum 不能为空");
- }
- $goodPrice = isset($post['goodPice']) && $post['goodPice'] !== '' ? $post['goodPice'] : '';
- if ($goodPrice == '') {
- return error_show(1004, "参数goodPrice 不能为空");
- }
- $good_total = isset($post['good_total']) && $post['good_total'] !== '' ? $post['good_total'] : '';
- if ($good_total == '') {
- return error_show(1004, "参数good_total 不能为空");
- }
- $contactor = isset($post['contactor']) && $post['contactor'] != '' ? trim($post['contactor']) : '';
- if ($contactor == '') {
- return error_show(1004, "参数contactor 不能为空");
- }
- $mobile = isset($post['mobile']) && $post['mobile'] != '' ? trim($post['mobile']) : '';
- if ($mobile == '') {
- return error_show(1004, "参数mobile 不能为空");
- }
- $addr = isset($post['addr']) && $post['addr'] != '' ? trim($post['addr']) : '';
- if ($addr == '') {
- return error_show(1004, "参数addr 不能为空");
- }
- $buyer = isset($post['buyer']) && $post['buyer'] != '' ? trim($post['buyer']) : '';
- if ($buyer == '') {
- return error_show(1004, "参数buyer 不能为空");
- }
- $buy_depart = isset($post['buy_depart']) && $post['buy_depart'] != '' ? trim($post['buy_depart']) : '';
- if ($buy_depart == '') {
- return error_show(1004, "参数buy_depart 不能为空");
- }
- $sendtime = isset($post['sendtime']) && $post['sendtime'] != '' ? $post['sendtime'] : '';
- if ($sendtime == '') {
- return error_show(1004, "参数sendtime 不能为空");
- }
- $cat_f = isset($post['cat_f']) && $post['cat_f'] != '' ? $post['cat_f'] : '';
- if ($cat_f == '') {
- return error_show(1004, "参数cat_f 不能为空");
- }
- $supplierNo = isset($post['supplierNo']) && $post['supplierNo'] != '' ? trim($post['supplierNo']) : '';
- if ($supplierNo == '') {
- return error_show(1004, "参数supplierNo 不能为空");
- }
- $supplier = Db::name('supplier_info')->where('code', "=", $supplierNo)->find();
- if (empty($supplier)) {
- return error_show(1004, "供应商信息未找到");
- }
- $cgd_tax = isset($post['cgd_tax']) && $post['cgd_tax'] !== '' ? round($post['cgd_tax']/100,4) : '';
- if ($cgd_tax === '') {
- return error_show(1004, "参数cgd_tax 不能为空");
- }
- $company = Db::name("company_info")->where("companyNo","=",$companyNo)->find();
- if(empty($company)){
- return error_show(1004, "确认单销售公司未找到");
- }
- $rate = Db::name('order_rate')->where('id',"=",$tax)->find();
- if(empty($rate)){
- return error_show(1004, "税率数据未找到");
- }
- $qrdno = makeNo("QRD");
- $Cgd = makeNo('CGD');
- $goodNo=makeNo("GY");
- $qrdData=[
- "name"=>'网络部确认单'.$sequenceNo,
- 'createdTime'=>date("Y-m-d H:i:s"),
- 'sequenceNo'=>$qrdno,
- 'sales_name'=>$sale_name,
- 'sales_depart'=>$department,
- 'customer'=>isset($cunstmer['companyName']) ? $cunstmer['companyName'] : "",
- 'total_fee'=>$good_total,
- 'mobile'=>$mobile,
- 'contactor'=>$contactor,
- 'qrddate'=>date("Y-m-d H:i:s"),
- 'companyNo'=>$khNo,
- 'supplerName'=>isset($company['company_name']) ? $company['company_name'] : "",
- 'addr'=>$addr,
- 'depart'=>$department,
- 'type'=>1,
- 'apay_fee'=>0,
- 'pay_fee'=>0,
- 'wpay_fee'=>$good_total,
- 'ainv_fee'=>0,
- 'inv_fee'=>0,
- 'winv_fee'=>$good_total,
- 'inv_status'=>1,
- 'pay_status'=>1,
- 'status'=>1,
- 'addtime'=>date("Y-m-d H:i:s"),
- 'updatetime'=>date("Y-m-d H:i:s")
- ];
- $data = [
- 'name' => '网络部确认单',
- 'createdTime' => date("Y-m-d H:i:s"),
- 'startTime' => date("Y-m-d H:i:s"),
- 'finishTime' => date("Y-m-d H:i:s"),
- "Date1617081795606"=>date("Y-m-d H:i:s"),
- // 'ownerName'=>date("Y-m-d H:i:s"),
- // 'departmentName'=>date("Y-m-d H:i:s"),
- 'sequenceNo' => $qrdno,
- 'sequenceStatus' => 1,
- 'ShortText1617022967356' => '网络部',
- 'text1617499162303'=>$goodNo,
- 'ShortText1617365292699' => $goodName,
- "ShortText1617367958909" => $rate['rate'].'%',
- 'text1617365646297'=>$poNo,
- "ShortText1618447165317"=>isset($company['company_name']) ? $company['company_name'] : "",
- "Number1617365688048" => $goodNum,
- 'ShortText1617650669915' => $qrdType,
- 'ShortText1617650701648' => $qrdno,
- "Number1618248810624" => $goodPrice,
- 'Number1618248813613' => $good_total,
- "Number1618249015661" => $goodNum,
- "number1618249149738" => $good_total,
- "Number1618249205231" => $good_total,
- 'ShortText1618446949933' => $contactor,
- 'ShortText1618446973813' => $mobile,
- 'LongText1618446982973' => $addr,
- 'ShortText1618559007040' => 3,
- 'ShortText1618559043560' => 1,
- 'ShortText1618559274859' => 1,
- "ShortText1617499192065"=>$cat_f,
- 'StaffSelector1619488013389' => $sale_name,
- 'ShortText1619523689586' => $department,
- 'ShortText1620750298602' => $supplierNo,
- 'ShortText1620750301301' => isset($supplier['name']) ? $supplier['name'] : "",
- 'Date1620370378620' => $sendtime,
- 'departmentName' => $department,
- 'ShortText1619542951283' => $khNo,
- 'ShortText1619523892833' => isset($cunstmer['companyName']) ? $cunstmer['companyName'] : "",
- 'StaffSelector1618445844046' => $sale_name,
- 'StaffSelector1618445850209' => $department,
- 'ownerName' => $sale_name,
- ];
- $data2 = [
- 'name'=>'网络部采购单',
- 'ownerName'=>$buyer,
- 'sequenceNo' => $Cgd,
- 'startTime' => date("Y-m-d H:i:s"),
- 'finishTime' => date("Y-m-d H:i:s"),
- "createdTime" => date("Y-m-d H:i:s"),
- "ShortText1618315935182"=>$Cgd,
- 'Date1618315953443'=>date("Y-m-d H:i:s"),
- "ShortText1617865626160" => $cat_f,
- "ShortText1617865688485" => $rate['rate']."%",
- "RelevanceForm1617861284547" => '',
- "ShortText1617866364821" => '',
- "ShortText1617866362204" => $qrdType,
- "ShortText1617866360004" =>$qrdno,
- "Number1618316157066" => $goodNum,
- "Number1618316171848" => 0,
- "ShortText1617861449444" => $contactor,
- "ShortText1617861455145" => $mobile,
- 'ShortText1617861001482'=>$goodNo,
- "ShortText1617861966146" => $goodName,
- "ShortText1618270466672" => isset($company['company_name'])?$company['company_name']:"",
- "Number1618330470625" => 0,
- "Number1618330472961" =>round($good_total*(1-$cgd_tax),2),
- "Number1618330541286" => 0,
- "Number1618330543270" =>round($good_total*(1-$cgd_tax),2),
- "StaffSelector1618885082387" => $buyer,
- "ShortText1619463188366" => 1,
- "ShortText1619463208482" => 1,
- "ShortText1620399144946" => isset($supplier['name']) ? $supplier['name'] : "",
- "ShortText1617861287265" => $supplierNo,
- "sequenceStatus" => 1,
- "department" => $buy_depart,
- "ShortText1618859321070"=>3,
- "ShortText1620753234895" => '',
- "ShortText1620753237335" => '',
- "Number1619625470651" => $goodNum,
- "Number1618240600907" => $goodNum,
- 'StaffSelector1620899427104'=>$buyer,
- 'Number1618240685904'=>round($good_total*(1-$cgd_tax),2)
- ];
- //var_dump($data);
- $td = [
- "return_ticket" => '',
- "return_trade" => '',
- "product_code" =>$goodNo,
- "product_name" => $goodName,
- "supplierNo" => $supplierNo,
- "suppierNo" => $supplierNo,
- 'companyNo'=>$khNo,
- "supplier" => isset($supplier['name']) ? $supplier['name'] : "",
- "cgd_tax" => $rate['rate']."%",
- "suplier_name" => isset($supplier['name']) ? $supplier['name'] : "",
- "unit" => '',
- 'ordertime'=>date("Y-m-d H:i:s"),
- "status" => 1,
- "productNo" => $qrdno,
- "order_num" => $goodNum,
- "sale_total" => $good_total,
- "sale_price" => $goodPrice,
- "apay_fee" => 0,
- "cat_f" =>$cat_f,
- "cgd_cat_f" =>$cat_f,
- "wpay_fee" => round($good_total*(1-$cgd_tax),2),
- "pay_status" => 1,
- "inv_fee" => 0,
- "winv_fee" => round($good_total*(1-$cgd_tax),2),
- "inv_status" => 1,
- "delivery_send" => $goodNum,
- "poNo" => $poNo,
- 'workNo'=>$sequenceNo,
- "qrdNo" => $qrdno,
- "qrd_type" => $qrdType,
- "qrd_ainv_fee" => 0,
- "qrd_winv_fee" => $good_total,
- "qrd_inv_status" => 1,
- "qrd_pay_status" => 1,
- "qrd_apay_fee" => 0,
- "qrd_wpay_fee" => $good_total,
- "qrd_invtime" => date("Y-m-d H:i:s"),
- "delivery_num" => $goodNum,
- "supperinfo" =>isset($company['company_name']) ? $company['company_name'] : "",
- "company" =>isset($company['company_name']) ? $company['company_name'] : "",
- "suppitem" => '网络部',
- "depart" => $department,
- "paytime" => date("Y-m-d H:i:s"),
- "cgdtime" => date("Y-m-d H:i:s"),
- "cgd_num" => $goodNum,
- "cgd_total" => round($good_total*(1-$cgd_tax),2),
- 'cgdNo'=>$Cgd,
- 'cgdjlNo'=>$Cgd,
- 'tax'=> $rate['rate']."%",
- "bktime" => date("Y-m-d H:i:s"),
- "saler" => $sale_name,
- "cgd_saler" => $buyer,
- "sale_name" => $sale_name,
- "cgd_good_name" => $goodName,
- "cgd_delivery_status" =>'已发',
- "delivery_wsend" => 0,
- "companyName" => isset($cunstmer['companyName']) ? $cunstmer['companyName'] : "",
- 'rate'=>$cgd_tax
- ];
- Db::startTrans();
- try {
- $a = Db::name("qrd_info")->insert($data);
- $d = Db::name("qrd")->insert($qrdData);
- $b = Db::name('cgd_info')->insert($data2);
- $c = Db::table('source_all')->insert($td);
- if ($a && $b && $c&&$d) {
- Db::commit();
- return app_show(0,'新建成功');
- } else {
- Db::rollback();
- return error_show(1004,'新建失败');
- }
- } catch (\Exception $e) {
- Db::rollback();
- return error_show(1004, $e->getMessage());
- }
- }
- public function edit(){
- $post = $this->request->post();
- $token = isset($post['token']) ? trim($post['token']) : "";
- if ($token == "") {
- return error_show(101, 'token不能为空');
- }
- $effetc = VerifyTokens($token);
- if (!empty($effetc) && $effetc['code'] != 0) {
- return error_show($effetc['code'], $effetc['message']);
- }
- $guserinfo = GetUserInfo($token);
- if (isset($guserinfo['code']) && $guserinfo['code'] != 0) {
- return error_show($guserinfo['code'], $guserinfo['message']);
- }
- $id = isset($post['id']) && $post['id'] != '' ? trim($post['id']) : '';
- if ($id == '') {
- return error_show(1004, "参数id 不能为空");
- }
- $source = Db::table('source_all')->where([['id',"=",$id]])->find();
- if(empty($source)){
- return error_show(1004, "数据未找到");
- }
- if(!isset($source['qrdNo'])||$source['qrdNo']==''){
- return error_show(1004, "数据未找到确认单号");
- }
- if(!isset($source['cgdNo'])||$source['cgdNo']==''){
- return error_show(1004, "数据未找到采购单号");
- }
- $qrd = Db::name('qrd')->where('sequenceNo',"=",$source['qrdNo'])->find();
- if(empty($qrd)){
- return error_show(1004, "确认单数据未找到");
- }
- $qrdinfo = Db::name('qrd_info')->where('ShortText1617650701648',"=",$source['qrdNo'])->find();
- if(empty($qrdinfo)){
- return error_show(1004, "确认单产品数据未找到");
- }
- $cat_f = isset($post['cat_f']) && $post['cat_f'] != '' ? $post['cat_f'] : '';
- if ($cat_f == '') {
- return error_show(1004, "参数cat_f 不能为空");
- }
- $cgdinfo = Db::name('cgd_info')->where('ShortText1618315935182',"=",$source['cgdNo'])->find();
- if(empty($cgdinfo)){
- return error_show(1004, "采购单数据未找到");
- }
- $pay = Db::name('pay_info')->alias('a')->join('cfp_pay b','a.payNo=b.payNo','left')->where("a.STATUS = 1
- AND (b.`status` = 2 or b.status=1) AND a.sequenceNo = '{$cgdinfo['sequenceNo']}' ")->find();
- if(!empty($pay)){
- return error_show(1004, "采购单数据正在对账中");
- }
- $qrdpay = Db::name('order_info')->alias('a')->join('cfp_order_pool b','a.orderNo = b.orderNo','left')
- ->where("a.status=1 and b.is_del=0 and a.qrdNo='{$source['qrdNo']}'")->find();
- if(!empty($qrdpay)){
- return error_show(1004, "确认单数据正在核算中");
- }
- $sale_name = isset($post['sale_name']) && $post['sale_name'] != '' ? trim($post['sale_name']) : '';
- if ($sale_name == '') {
- return error_show(1004, "参数sale_name 不能为空");
- }
- $poNo = isset($post['poNo']) && $post['poNo'] != '' ? trim($post['poNo']) : '';
- if ($poNo == '') {
- return error_show(1004, "参数poNo 不能为空");
- }
- $sequenceNo = isset($post['sequenceNo']) && $post['sequenceNo'] != '' ? trim($post['sequenceNo']) : '';
- if ($sequenceNo == '') {
- return error_show(1004, "参数sequenceNo 不能为空");
- }
- $department = isset($post['department']) && $post['department'] != '' ? trim($post['department']) : '网络部';
- $companyNo = isset($post['companyNo']) && $post['companyNo'] != '' ? trim($post['companyNo']) : '';
- if ($companyNo == '') {
- return error_show(1004, "参数companyNo 不能为空");
- }
- $company = Db::name("company_info")->where("companyNo","=",$companyNo)->find();
- if(empty($company)){
- return error_show(1004, "确认单销售公司未找到");
- }
- $khNo = isset($post['khNo']) && $post['khNo'] != '' ? trim($post['khNo']) : '';
- if ($khNo == '') {
- return error_show(1004, "参数khNo 不能为空");
- }
- $cunstmer = Db::name('customer_info')->where('companyNo', "=", $khNo)->find();
- if (empty($cunstmer)) {
- return error_show(1004, "客户信息未找到");
- }
- $qrdType = isset($post['qrdType']) && $post['qrdType'] != '' ? trim($post['qrdType']) : '';
- if ($qrdType == '') {
- return error_show(1004, "参数qrdType 不能为空");
- }
- $goodName = isset($post['goodName']) && $post['goodName'] != '' ? trim($post['goodName']) : '';
- if ($goodName == '') {
- return error_show(1004, "参数goodName 不能为空");
- }
- $tax = isset($post['tax']) && $post['tax'] != '' ? trim($post['tax']) : '';
- if ($tax == '') {
- return error_show(1004, "参数tax 不能为空");
- }
- $goodNum = isset($post['goodNum']) && $post['goodNum'] !== '' ? intval($post['goodNum']) : '';
- if ($goodNum === '') {
- return error_show(1004, "参数goodNum 不能为空");
- }
- $goodPrice = isset($post['goodPice']) && $post['goodPice'] !== '' ? $post['goodPice'] : '';
- if ($goodPrice == '') {
- return error_show(1004, "参数goodPrice 不能为空");
- }
- $good_total = isset($post['good_total']) && $post['good_total'] !== '' ? $post['good_total'] : '';
- if ($good_total == '') {
- return error_show(1004, "参数good_total 不能为空");
- }
- $contactor = isset($post['contactor']) && $post['contactor'] != '' ? trim($post['contactor']) : '';
- if ($contactor == '') {
- return error_show(1004, "参数contactor 不能为空");
- }
- $mobile = isset($post['mobile']) && $post['mobile'] != '' ? trim($post['mobile']) : '';
- if ($mobile == '') {
- return error_show(1004, "参数mobile 不能为空");
- }
- $addr = isset($post['addr']) && $post['addr'] != '' ? trim($post['addr']) : '';
- if ($addr == '') {
- return error_show(1004, "参数addr 不能为空");
- }
- $buyer = isset($post['buyer']) && $post['buyer'] != '' ? trim($post['buyer']) : '';
- if ($buyer == '') {
- return error_show(1004, "参数buyer 不能为空");
- }
- $buy_depart = isset($post['buy_depart']) && $post['buy_depart'] != '' ? trim($post['buy_depart']) : '';
- if ($buy_depart == '') {
- return error_show(1004, "参数buy_depart 不能为空");
- }
- $sendtime = isset($post['sendtime']) && $post['sendtime'] != '' ? $post['sendtime'] : '';
- if ($sendtime == '') {
- return error_show(1004, "参数sendtime 不能为空");
- }
- $supplierNo = isset($post['supplierNo']) && $post['supplierNo'] != '' ? trim($post['supplierNo']) : '';
- if ($supplierNo == '') {
- return error_show(1004, "参数supplierNo 不能为空");
- }
- $supplier = Db::name('supplier_info')->where('code', "=", $supplierNo)->find();
- if (empty($supplier)) {
- return error_show(1004, "供应商信息未找到");
- }
- $cgd_tax = isset($post['cgd_tax']) && $post['cgd_tax'] !== '' ? round($post['cgd_tax']/100,4) : '';
- if ($cgd_tax === '') {
- return error_show(1004, "参数cgd_tax 不能为空");
- }
- $rate = Db::name('order_rate')->where('id',"=",$tax)->find();
- if(empty($rate)){
- return error_show(1004, "税率数据未找到");
- }
- $qrdData=[
- "name"=>'网络部确认单'.$sequenceNo,
- 'createdTime'=>date("Y-m-d H:i:s"),
- 'sales_name'=>$sale_name,
- 'sales_depart'=>$department,
- 'customer'=>isset($cunstmer['companyName']) ? $cunstmer['companyName'] : "",
- 'total_fee'=>$good_total,
- 'mobile'=>$mobile,
- 'contactor'=>$contactor,
- 'qrddate'=>date("Y-m-d H:i:s"),
- 'companyNo'=>$khNo,
- 'supplerName'=>isset($company['company_name']) ?$company['company_name']: "",
- 'addr'=>$addr,
- 'depart'=>$department,
- 'wpay_fee'=>$good_total,
- 'winv_fee'=>$good_total,
- 'updatetime'=>date("Y-m-d H:i:s")
- ];
- $data = [
- 'ShortText1617365292699' => $goodName,
- "ShortText1617367958909" => $rate['rate'].'%',
- 'text1617365646297'=>$poNo,
- "Number1617365688048" => $goodNum,
- 'ShortText1617650669915' => $qrdType,
- "Number1618248810624" => $goodPrice,
- 'Number1618248813613' => $good_total,
- "Number1618249015661" => $goodNum,
- "number1618249149738" => $good_total,
- "Number1618249205231" => $good_total,
- 'ShortText1618446949933' => $contactor,
- 'ShortText1618446973813' => $mobile,
- 'LongText1618446982973' => $addr,
- "ShortText1617499192065"=>$cat_f,
- 'StaffSelector1619488013389' => $sale_name,
- 'ShortText1619523689586' => $department,
- 'ShortText1620750298602' => $supplierNo,
- 'ShortText1620750301301' => isset($supplier['name']) ? $supplier['name'] : "",
- 'Date1620370378620' => $sendtime,
- 'departmentName' => $department,
- 'ShortText1619542951283' => $khNo,
- "ShortText1618447165317"=>isset($company['company_name']) ? $company['company_name'] : "",
- 'ShortText1619523892833' => isset($cunstmer['companyName']) ? $cunstmer['companyName'] : "",
- 'StaffSelector1618445844046' => $sale_name,
- 'StaffSelector1618445850209' => $department,
- 'ownerName' => $sale_name,
- 'finishTime'=>date("Y-m-d H:i:s")
- ];
- $data2 = [
- 'ownerName'=>$buyer,
- "ShortText1617865688485" => $rate['rate']."%",
- "ShortText1617866362204" => $qrdType,
- "Number1618316157066" => $goodNum,
- "Number1618316171848" => 0,
- "ShortText1617861449444" => $contactor,
- "ShortText1617861455145" => $mobile,
- "ShortText1617861966146" => $goodName,
- "Number1618330472961" => round($good_total*(1-$cgd_tax),2),
- "Number1618330543270" => round($good_total*(1-$cgd_tax),2),
- "StaffSelector1618885082387" => $buyer,
- "ShortText1620399144946" => isset($supplier['name']) ? $supplier['name'] : "",
- "ShortText1617861287265" => $supplierNo,
- "department" => $buy_depart,
- "ShortText1618859321070"=>3,
- "ShortText1617865626160"=>$cat_f,
- "Number1619625470651" => $goodNum,
- "Number1618240600907" => $goodNum,
- "ShortText1618270466672" => isset($company['company_name'])?$company['company_name']:"",
- 'Number1618240685904'=>round($good_total*(1-$cgd_tax),2),
- 'finishTime'=>date("Y-m-d H:i:s")
- ];
- //var_dump($data);
- $td = [
- "product_name" => $goodName,
- 'companyNo'=>$khNo,
- "supplierNo" => $supplierNo,
- "suppierNo" => $supplierNo,
- "supplier" => isset($supplier['name']) ? $supplier['name'] : "",
- "cgd_tax" => $rate['rate']."%",
- "suplier_name" => isset($supplier['name']) ? $supplier['name'] : "",
- "order_num" => $goodNum,
- "sale_total" => $good_total,
- "sale_price" => $goodPrice,
- "wpay_fee" => round($good_total*(1-$cgd_tax),2),
- "winv_fee" => round($good_total*(1-$cgd_tax),2),
- "delivery_send" => $goodNum,
- "poNo" => $poNo,
- "cat_f" =>$cat_f,
- "cgd_cat_f" =>$cat_f,
- 'workNo'=>$sequenceNo,
- "qrd_type" => $qrdType,
- "qrd_winv_fee" => $good_total,
- "qrd_wpay_fee" => $good_total,
- "delivery_num" => $goodNum,
- "depart" => $department,
- "cgd_num" => $goodNum,
- "cgd_total" => round($good_total*(1-$cgd_tax),2),
- 'tax'=> $rate['rate']."%",
- "saler" => $sale_name,
- "cgd_saler" => $buyer,
- "sale_name" => $sale_name,
- "cgd_good_name" => $goodName,
- "delivery_wsend" => 0,
- "companyName" => isset($cunstmer['companyName']) ? $cunstmer['companyName'] : "",
- "supperinfo" =>isset($company['company_name']) ? $company['company_name'] : "",
- "company" =>isset($company['company_name']) ? $company['company_name'] : "",
- 'rate'=>$cgd_tax,
- 'cgdtime'=>date("Y-m-d H:i:s")
- ];
- Db::startTrans();
- try {
- $a = Db::name("qrd_info")->where('id','=',$qrdinfo['id'])->save($data);
- $d = Db::name("qrd")->where('id','=',$qrd['id'])->save($qrdData);
- $b = Db::name('cgd_info')->where('id','=',$cgdinfo['id'])->save($data2);
- $c = Db::table('source_all')->where('id','=',$id)->save($td);
- if ($a && $b && $c&&$d) {
- Db::commit();
- return app_show(0,'修改成功');
- } else {
- Db::rollback();
- return error_show(1004,'修改失败');
- }
- } catch (\Exception $e) {
- Db::rollback();
- return error_show(1004, $e->getMessage());
- }
- }
- public function info(){
- $post=$this->request->post();
- $id = isset($post['id'])&&$post['id']!='' ? $post['id'] :"";
- $condition = [['a.id',"=",$id]];
- $list=Db::table('source_all')->alias('a')->join('cfp_qrd_info b','a.productNo=b.sequenceNo','left')
- ->join('cfp_cgd_info c','a.cgdNo=c.ShortText1618315935182','left')->where($condition)
- ->order("a.ordertime desc")->field('a.id,
- a.productNo as qrdcpNo,
- a.qrdNo,
- a.companyNo as khNo,
- a.companyName as knName,
- a.supperinfo,
- a.suppitem,
- a.poNo,
- a.workNo as sequenceNo,
- a.ordertime,
- a.sale_name,
- a.depart as department,
- a.product_name as goodName,
- a.tax,
- a.cat_f,
- a.sale_price as goodPice,
- a.order_num as goodNum,
- a.sale_total as good_total,
- a.qrd_type as qrdType,
- a.supplier,
- a.supplierNo,
- a.cgdNo,
- a.cgd_saler as buyer,
- c.department as buy_depart,
- b.Date1620370378620 as sendtime,
- a.rate*100 as cgd_tax,
- b.ShortText1618446949933 as contactor,
- b.ShortText1618446973813 as mobile,
- b.LongText1618446982973 as addr
- ')->find();
- if(empty($list)){
- return error_show(1004,'未找到数据');
- }
- $company = Db::name('company_info')->where('company_name',"=",$list['supperinfo'])->find();
- $list['companyNo'] = isset($company['companyNo']) ? $company['companyNo']:"";
- $rateid = Db::name("order_rate")->where('rate',"=",str_replace("%","",$list['tax']))->find();
- $list['rateid'] = isset($rateid['id'])?$rateid['id'] : 0;
- return app_show(0,"获取成功",$list);
- }
- public function getCat(){
- $post=$this->request->post();
- $condition = [['status',"=",1]];
- $pid = isset($post['pid'])&&$post['pid']!==""? $post['pid'] :'0';
- if($pid!==''){
- $condition[]=["pid","=",$pid];
- }
- $level= isset($post['level'])&&$post['level']!==""? $post['level'] :'1';
- if($level!=""){
- $condition[]=["level","=",$level];
- }
- $cat = Db::name("cat")->where($condition)->field("id,cat_name,level")->order("weight desc ,addtime desc")
- ->select();
- return app_show(0,"获取成功",$cat);
- }
- }
|