Purch.php 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\model\ActionLog;
  4. use app\admin\model\DataGroup as DataGroupModel;
  5. use app\admin\model\ProcessOrder;
  6. use think\App;
  7. use think\Exception;
  8. use think\facade\Db;
  9. use think\facade\Validate;
  10. //采购单相关功能
  11. class Purch extends Base
  12. {
  13. public $noble=[];
  14. public function __construct(App $app)
  15. {
  16. parent::__construct($app);
  17. $this->noble=\think\facade\Config::get("noble");
  18. }
  19. //采购单列表
  20. public function list(){
  21. $page = isset($this->post['page']) && $this->post['page'] !=="" ? intval($this->post['page']):"1";
  22. $size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']):"10";
  23. $where = [['po.is_del', "=", 0]];
  24. $bkcode = isset($this->post['bk_code']) && $this->post['bk_code']!="" ? trim($this->post['bk_code']):"";
  25. if($bkcode!==""){
  26. $where[]=['po.bkcode',"like", "%{$bkcode}%"];
  27. }
  28. $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
  29. if($status!==""){
  30. // $where['status'] = $status;
  31. $where[]=['po.status',"=", $status];
  32. }
  33. $cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo']!="" ? trim($this->post['cgdNo']) :"";
  34. if($cgdNo!==""){
  35. //$where['cgdNo'] = Db::Raw("like '%{$cgdNo}%'");
  36. $where[]=['po.cgdNo',"like", "%{$cgdNo}%"];
  37. }
  38. $apply_name = isset($this->post['apply_name']) && $this->post['apply_name']!="" ? trim($this->post['apply_name']):"";
  39. if($apply_name!==""){
  40. // $where['cgder'] =Db::Raw("like '%{$apply_name}%'");
  41. $where[]=['po.cgder',"like", "%{$apply_name}%"];
  42. }
  43. $wsm_code = isset($this->post['wsm_code']) && $this->post['wsm_code']!="" ? trim($this->post['wsm_code']):"";
  44. if($wsm_code!==""){
  45. // $where['wsm_code'] = $wsm_code;
  46. $where[]=['po.wsm_code',"=", $wsm_code];
  47. }
  48. $wsm_in_code = isset($this->post['wsm_in_code']) && $this->post['wsm_in_code']!="" ? trim($this->post['wsm_in_code']):"";
  49. if($wsm_in_code!==""){
  50. $incode = Db::name("purchease_in")->where(["wsm_in_code"=>Db::raw(" like %{$wsm_in_code}%"),"is_del"=>0])->column("cgdNo");
  51. if(empty($incode)){
  52. return error_show(1004,"未找到有关入库单信息");
  53. }
  54. $where[]=['po.cgdNo',"in", $incode];
  55. }
  56. $good_name = isset($this->post['good_name']) && $this->post['good_name']!="" ? trim($this->post['good_name']):"";
  57. if($good_name!==""){
  58. //$where['good_name'] = Db::raw(" like %{$good_name}%");
  59. $where[]=['po.good_name',"like", "%{$good_name}%"];
  60. }
  61. $good_code = isset($this->post['good_code']) && $this->post['good_code']!="" ? trim($this->post['good_code']) :"";
  62. if($good_code!==""){
  63. // $where['good_code'] = Db::raw(" like %{$good_code}%");
  64. $where[]=['po.spuCode',"like", "%{$good_code}%"];
  65. }
  66. $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo']!="" ? trim($this->post['supplierNo']) :"";
  67. if($supplierNo!==""){
  68. // $where['good_code'] = Db::raw(" like %{$good_code}%");
  69. $where[]=['po.supplierNo',"=", $supplierNo];
  70. }
  71. $wsm_supplierNo = isset($this->post['wsm_supplierNo']) && $this->post['wsm_supplierNo']!="" ? trim($this->post['wsm_supplierNo']) :"";
  72. if($wsm_supplierNo!==""){
  73. // $supplier = Db::name("supplier")->where(["code"=>$wsm_supplierNo])->find();
  74. // if(empty($supplier)){
  75. // return error_show(1004,"未找到供应商信息");
  76. // }
  77. $wsmcode = Db::name("warehouse_info")->where(["is_del"=>0,"supplierNo"=>$wsm_supplierNo])->column("wsm_code");
  78. $where[]=['po.wsm_code',"in", $wsmcode];
  79. }
  80. $start = isset($this->post['start']) && $this->post['start']!="" ?$this->post['start']:"";
  81. if($start!==""){
  82. // $where['addtime'] = Db::raw(" >= '{$start}'");
  83. $where[]=['po.addtime',">=", $start." 00:00:00"];
  84. }
  85. $end = isset($this->post['end']) && $this->post['end']!="" ?$this->post['end']:"";
  86. if($end!==""){
  87. $where[]=['po.addtime',"<=", $end." 23:59:59"];
  88. }
  89. $last_start = isset($this->post['last_start']) && $this->post['last_start']!="" ?$this->post['last_start']:"";
  90. if($last_start!==""){
  91. //$where['lasttime'] = Db::raw(" >= '{$last_start}'");
  92. $where[]=['po.lasttime',">=", $last_start." 00:00:00"];
  93. }
  94. $last_end = isset($this->post['last_end']) && $this->post['last_end']!="" ?$this->post['last_end']:"";
  95. if($last_end!==""){
  96. //$where['lasttime'] = Db::raw(" <= '{$last_end}'");
  97. $where[]=['po.lasttime',"<=", $last_end." 23:59:59"];
  98. }
  99. $orderCode = isset($this->post['orderCode']) && $this->post['orderCode']!="" ?$this->post['orderCode']:"";
  100. if($orderCode!==""){
  101. //$where['lasttime'] = Db::raw(" <= '{$last_end}'");
  102. $where[]=['on.orderCode',"like", '%'.$orderCode.'%'];
  103. }
  104. //筛选供应商名称
  105. $supplier_name = isset($this->post['supplier_name']) && $this->post['supplier_name'] != "" ? $this->post['supplier_name'] : "";
  106. if ($supplier_name != '') $where[] = ['po.supplier_name', 'like', '%' . $supplier_name . '%'];
  107. $relaComNo = isset($this->post['relaComNo']) && $this->post['relaComNo'] != "" ? trim($this->post['relaComNo']) : "";
  108. if ($relaComNo !== "") $where[] = ['po.companyNo', '=', $relaComNo];
  109. // $whereor=[];
  110. // if(!empty($role['write'])){
  111. //// $whereor[]=["po.cgder_id","in",$role['write']];
  112. //// $whereor[]=["sip.personid","=",$this->uid];
  113. // $whereor[]=["sip.personid","in",$role['write']];//最后的筛选条件
  114. //// $whereor[]=["po.cgder_id","=",$this->uid];
  115. // }
  116. // $role = $this->checkDataShare();
  117. // if (!empty($role[DataGroupModel::$type_全部])) $where[] = ["sip.personid", "in", $role[DataGroupModel::$type_全部]];
  118. //只有level2的账号过滤数据权限
  119. if ($this->level == 2) {
  120. $role = $this->checkDataShare();
  121. $hand = resign_hand_user($this->uid, 0);
  122. if (!empty($role[DataGroupModel::$type_全部])) {
  123. $arr = array_unique(array_merge($hand, $role[DataGroupModel::$type_全部]));
  124. $where[] = ['sip.personid', 'in', $arr];
  125. }
  126. }
  127. $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
  128. if ($company_name !== "") $where[] = ["po.cgder_id", 'in', get_company_item_user_by_name($company_name)];
  129. $order_type = isset($this->post['order_type']) && $this->post['order_type'] !== "" ? intval($this->post['order_type']) : "";
  130. if ($order_type !== "") $where[] = ["po.order_type", '=', $order_type];
  131. $order_source = isset($this->post['order_source']) && $this->post['order_source'] !== "" ? intval($this->post['order_source']) : "";
  132. if ($order_source !== "") $where[] = ["po.order_source", '=', $order_source];
  133. // if(!empty($role['platform']) ){
  134. // $where[]=["po.platform_id","in",$role['platform']];
  135. // }
  136. $count = Db::name("purchease_order")
  137. ->alias('po')
  138. ->leftJoin('order_num on', 'on.cgdNo=po.cgdNo')
  139. ->leftJoin("depart_user u", "u.uid=po.cgder_id AND u.is_del=0")
  140. ->leftJoin('supplier sip', 'sip.code=po.supplierNo')
  141. ->where($where)
  142. ->where(function ($query) use ($where) {
  143. $query->whereOr([['po.order_type', '<>', 1], ['po.order_source', '=', 0]]);
  144. })->count();
  145. $total = ceil($count/$size);
  146. $page = $page >= $total ? $total : $page;
  147. $list = Db::name("purchease_order")
  148. ->alias('po')
  149. ->leftJoin('order_num on','on.cgdNo=po.cgdNo')
  150. ->leftJoin('supplier sip', 'sip.code=po.supplierNo')
  151. ->field('po.*,on.orderCode,sip.personid as supplier_cgderid,sip.person as supplier_cgder')
  152. ->where($where)
  153. ->where(function($query) use ($where){$query->whereOr([['po.order_type', '<>', 1],['po.order_source', '=', 0]]);})
  154. ->page($page,$size)
  155. ->order("po.addtime desc")
  156. ->select()
  157. ->toArray();
  158. $account = checkHasAccountBySupplierNos(array_column($list,'supplierNo'));
  159. $all_createrid = array_column($list,'cgder_id');
  160. $item = get_company_name_by_uid($all_createrid);
  161. $data=[];
  162. $wsmCodes = array_column($list,'wsm_code');
  163. $wsmcode = Db::name("warehouse_info")->alias("a")
  164. ->where(["a.wsm_code"=>$wsmCodes])->column("a.name as wsm_name,a.supplierNo as code","wsm_code");
  165. $userCommon = new \app\admin\common\User();
  166. $wsmsupplier=[];
  167. if(!empty($wsmcode)){
  168. $names = $userCommon->handle('getCodeAndName', ['code' => array_column($wsmcode,"code")]);
  169. $wsmsupplier = $names['data']??[];
  170. }
  171. foreach ($list as $value){
  172. $value['wsm_name'] =isset($wsmcode[$value['wsm_code']]['wsm_name']) ? $wsmcode[$value['wsm_code']]['wsm_name']:"";
  173. $value['wsm_supplier'] =$wsmsupplier[$wsmcode[$value['wsm_code']]['code']]??"";
  174. $value['wsm_supplierNo'] =$wsmcode[$value['wsm_code']]['code']??"";
  175. // $value['wsm_name']="";
  176. // if($value['wsm_code']!=""){
  177. //// $wsmcode = Db::name("warehouse_info")->alias("a")->leftJoin("supplier b","a.supplierNo=b.code")
  178. //// ->where(["a.wsm_code"=>$value['wsm_code']])->field("a.name as wsm_name,b.name,b.code")->find();
  179. // $value['wsm_name'] =isset($wsmcode['wsm_name']) ? $wsmcode['wsm_name']:"";
  180. // $value['wsm_supplier'] =isset($wsmcode['name']) ? $wsmcode['name']:"";
  181. // $value['wsm_supplierNo'] =isset($wsmcode['code']) ? $wsmcode['code']:"";
  182. // }
  183. // $supplierCgder =Db::name("supplier")->where(["code"=>$value['supplierNo']])->findOrEmpty();
  184. // $value['supplier_cgderid'] = $supplierCgder['personid'] ??'';
  185. // $value['supplier_cgder'] = $supplierCgder['person'] ??'';
  186. if($value['order_type']==3){
  187. $goon = Db::name("good_zixun")->where(["spuCode"=>$value['spuCode'],"is_del"=>0])->find();
  188. $value["speclist"]=isset($goon['specinfo'])&&$goon['specinfo']!=""? json_decode($goon['specinfo'],true):"";
  189. }else {
  190. $goon =Db::name('good_basic')->where(['spuCode'=>$value['spuCode']])->find();
  191. $spec = Db::name("good_spec")->where(["spuCode"=>$goon['spuCode'],"is_del"=>0])->select()->toArray();
  192. $speclist=[];
  193. if(!empty($spec)){
  194. foreach ($spec as $val){
  195. $temp=[];
  196. $temp['id']=$val['id'];
  197. $temp['spuCode']=$val['spuCode'];
  198. $temp['spec_id']=$val['spec_id'];
  199. $temp['spec_value_id']=$val['spec_value_id'];
  200. $sp = Db::name("specs")->where(["id"=>$val['spec_id']])->find();
  201. $temp['spec_name']=isset($sp["spec_name"]) ? $sp["spec_name"]:"";
  202. $spv = Db::name("spec_value")->where(["id"=>$val['spec_value_id']])->find();
  203. $temp['spec_value']=isset($spv["spec_value"]) ? $spv["spec_value"]:"";
  204. $speclist[]=$temp;
  205. }
  206. }
  207. $value["speclist"]=empty($speclist)?[]:$speclist;
  208. }
  209. //采购单详情字段order_type 为1或者2时,取线上商品库 商品创建人 order_type 为3或者4时 取采购反馈的商品库 商品反馈人
  210. // $value['cgder_id'] = $goon['createrid'];
  211. // $value['cgder'] = $goon['creater'];
  212. $inorder= Db::name("purchease_in")
  213. ->where(['cgdNo'=>$value['cgdNo'],"is_del"=>0])
  214. ->select()
  215. ->toArray();
  216. $value['child']=empty($inorder)? [] : $inorder;
  217. $value['send_num'] -=$value['th_num'];
  218. $value['total_fee'] =round($value['total_fee']-$value['th_fee'],2);
  219. //补充orderCode
  220. // $value['orderCode']=isset($all_orderCodes[$value['cgdNo']])?$all_orderCodes[$value['cgdNo']]:'';
  221. $value['company_name'] = $item[$value['cgder_id']]??'';
  222. $value['has_account'] = (int)isset($account[$value['supplierNo']]);
  223. //是否具有编辑权限
  224. // $value['is_allow_update'] = 0;
  225. // if (in_array($this->roleid, [1, 33]) || in_array($value['cgder_id'], $role[DataGroupModel::$type_可编辑])) $value['is_allow_update'] = 1;
  226. $data[]=$value;
  227. }
  228. return app_show(0,"获取成功",["list"=>$data ,"count"=>$count]);
  229. }
  230. public function info(){
  231. $cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo']!="" ?trim($this->post['cgdNo']):"";
  232. if($cgdNo==""){
  233. return error_show(1004,"参数cgdNo 不能为空");
  234. }
  235. //采购单
  236. $data = Db::name("purchease_order")->where(["cgdNo"=>$cgdNo,"is_del"=>0])->find();
  237. if(empty($data)){
  238. return error_show(1004,"未找到数据");
  239. }
  240. //采购退货单
  241. $im = Db::name('purchease_back')->where(['cgdNo'=>$data['cgdNo'],'is_del'=>0])->select();
  242. $var=[];
  243. foreach ($im as $value){
  244. if($data['order_type']==3){
  245. $goo = Db::name("good_zixun")->where(["spuCode"=>$value['spuCode'],"is_del"=>0])->find();
  246. }else {
  247. $goo =Db::name('good_basic')->where(['spuCode'=>$value['spuCode']])->find();
  248. }
  249. if($goo==false) {
  250. return error_show(1002, "未找到商品数据");
  251. }
  252. $cat= isset($goo['cat_id']) && $goo['cat_id'] !=0 ? made($goo['cat_id']):[];
  253. $value['cant']=$cat;
  254. $var[]=$value;
  255. }
  256. //采购工差单
  257. $dom = Db::name("purchease_diff")->where(['cgdNo'=>$data['cgdNo'],'is_del'=>0])->find();
  258. if($data['order_type']==3){
  259. $goon = Db::name("good_zixun")->where(["spuCode"=>$data['spuCode'],"is_del"=>0])->find();
  260. }else {
  261. $goon =Db::name('good_basic')->where(['spuCode'=>$data['spuCode']])->find();
  262. }
  263. if(empty($goon)){
  264. return error_show(1002,"未找到商品数据");
  265. }else{
  266. $goon['exclusive']=isset($goon['is_exclusive'])?makeExcluse($goon['is_exclusive']):"";
  267. $unit =Db::name("unit")->where(["id"=>$goon['good_unit']])->find();
  268. $goon['unit'] = isset($unit['unit'])?$unit['unit']:'';
  269. $spec = Db::name("good_spec")->where(["spuCode"=>$goon['spuCode'],"is_del"=>0])->select()->toArray();
  270. $speclist=[];
  271. if(!empty($spec)){
  272. foreach ($spec as $value){
  273. $temp=[];
  274. $temp['id']=$value['id'];
  275. $temp['spuCode']=$value['spuCode'];
  276. $temp['spec_id']=$value['spec_id'];
  277. $temp['spec_value_id']=$value['spec_value_id'];
  278. $temp['is_del']=$value['is_del'];
  279. $sp = Db::name("specs")->where(["id"=>$value['spec_id']])->find();
  280. $temp['spec_name']=isset($sp["spec_name"]) ? $sp["spec_name"]:"";
  281. $spv = Db::name("spec_value")->where(["id"=>$value['spec_value_id']])->find();
  282. $temp['spec_value']=isset($spv["spec_value"]) ? $spv["spec_value"]:"";
  283. $speclist[]=$temp;
  284. }
  285. }
  286. $goon["speclist"]=empty($speclist)?[]:$speclist;
  287. $proof =Db::name("good_proof")->where(["spuCode"=>$goon['spuCode'],"is_del"=>0])->order("updatetime desc")->field("id,proof_type,proof_url")->find();
  288. $goon['proof'] = isset($proof)&&$proof!=false? $proof:[];
  289. $goon['origin_place_cn']="";
  290. $goon['delivery_place_cn']="";
  291. if(isset($goon['delivery_place'])&&$goon['delivery_place']!==""){
  292. $place = ["provice_code"=>"","city_code"=>"","area_code"=>""];
  293. list($place['provice_code'],$place['city_code'],$place['area_code'])=explode(",",$goon['delivery_place']);
  294. $goon['delivery_place_cn']=GetAddr(json_encode($place));
  295. }
  296. if(isset($goon['delivery_place'])&&$goon['origin_place']!==""){
  297. $place = ["provice_code"=>"","city_code"=>"","area_code"=>""];
  298. list($place['provice_code'],$place['city_code'],$place['area_code'])=explode(",",$goon['origin_place']);
  299. $goon['origin_place_cn']=GetAddr(json_encode($place));
  300. }
  301. if($goon['brand_id']!=0){
  302. $brand=Db::name("brand")->where(["id"=>$goon['brand_id']])->find();
  303. $goon["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  304. }else{
  305. $goon["brand_name"]="";
  306. $goon["brand_id"]="";
  307. }
  308. $userCommon = new \app\admin\common\User();
  309. $supplier = $userCommon->handle('sInfo',['code'=>$goon['supplierNo']]);
  310. // $supplier = Db::name("supplier")->where(["code"=>$goon['supplierNo']])->find();
  311. $goon['supplier_cgderid'] = $supplier['data']['personid'] ??'';
  312. $goon['supplier_cgder'] = $supplier['data']['person'] ??'';
  313. $goon['supplierName'] = isset($supplier['data']['name'])?$supplier['data']['name']:"";
  314. $goon['noble_name']=isset($goon['noble_metal'])&&$goon['noble_metal']!=0?$this->noble[$goon['noble_metal']] :"";
  315. //补充客户名称
  316. if (empty($data['orderCode'])) $data['customer'] = [];
  317. else {
  318. $customer_code = Db::name('sale')
  319. ->alias('s')
  320. // ->field('c.companyNo,c.companyName')
  321. // ->leftJoin('customer_info c', 'c.companyNo=s.customer_code AND c.is_del=0')
  322. ->where(['s.orderCode' => $data['orderCode']])
  323. ->value('s.customer_code','');
  324. }
  325. $tmp = $userCommon->handle('getCodeAndName', ['code' => [
  326. $goon['companyNo'],
  327. $data['wsm_code'],
  328. $data['companyNo'],
  329. $customer_code
  330. ]]);
  331. if(!empty($data['orderCode'])){
  332. $data['customer']['companyNo'] = $customer_code;
  333. $data['customer']['companyName'] = $tmp['data'][$customer_code]??'';
  334. }
  335. if(isset($goon['companyNo'])&&$goon['companyNo']!=""){
  336. // $company = Db::name("business")->where(["companyNo"=>$goon['companyNo']])->find();
  337. }
  338. $goon['company'] = $tmp['data'][$goon['companyNo']] ?? '';
  339. }
  340. $int= isset($goon['cat_id']) && $goon['cat_id'] !=0 ? made($goon['cat_id']):[];
  341. $data['wsm_name']="";
  342. if($data['wsm_code']!=""){
  343. $wsmcode = Db::name("warehouse_info")
  344. ->alias("a")
  345. // ->leftJoin("supplier b","a.supplierNo=b.code")
  346. ->leftJoin("warehouse_addr c","a.wsm_code=c.wsm_code and c.is_del=0")
  347. ->where(["a.wsm_code"=>$data['wsm_code']])
  348. ->field("a.name as wsm_name,c.wsm_name as wsm_contactor,c.wsm_mobile,c.wsm_addr,c.addr_code")
  349. ->find();
  350. $data['wsm_name'] =isset($wsmcode['wsm_name']) ? $wsmcode['wsm_name']:"";
  351. $data['wsm_supplier'] =isset($wsmcode['data'][$data['wsm_code']]) ? $wsmcode['data'][$data['wsm_code']]:"";
  352. $data['wsm_supplierNo'] =isset($wsmcode['data'][$data['wsm_code']]) ? $wsmcode['data'][$data['wsm_code']]:"";
  353. $data['wsm_contactor'] =isset($wsmcode['wsm_contactor']) ? $wsmcode['wsm_contactor']:"";
  354. $data['wsm_mobile'] =isset($wsmcode['wsm_mobile']) ? $wsmcode['wsm_mobile']:"";
  355. // $data['wsm_addr'] =isset($wsmcode['wsm_addr']) ? $wsmcode['wsm_addr']:"";
  356. $data['addr_code'] =isset($wsmcode['addr_code']) ? $wsmcode['addr_code']:"";
  357. $data['wsm_addr'] =isset($wsmcode['addr_code']) ? GetAddr($wsmcode['addr_code']):"";
  358. $data['wsm_addr'].=isset($wsmcode['wsm_addr']) ? $wsmcode['wsm_addr']:"";
  359. $inorder= Db::name("purchease_in")->where(['cgdNo'=>$data['cgdNo'],"is_del"=>0])->select();
  360. $data['child']=empty($inorder)? [] : $inorder;
  361. }
  362. $data['can'] = $int;
  363. $data['goodinfo'] = $goon;
  364. $data['purcheasediff'] = $dom;
  365. $data['send_num'] -=$data['th_num'];
  366. $data['total_fee'] =round($data['total_fee']-$data['th_fee'],2);
  367. $data['company'] = '';
  368. if (isset($data['companyNo']) && $data['companyNo'] != "") {
  369. // $company = Db::name("business")->where(["companyNo"=>$data['companyNo']])->find();
  370. $data['company'] = $tmp['data'][$data['companyNo']] ?? '';
  371. }
  372. //$data['company'] = isset($company['company'])?$company['company']:"";
  373. //$data['info'] = $var;
  374. $data['purcheaseback'] = $var;
  375. //补充orderCode
  376. $data['orderCode'] = Db::name('order_num')
  377. ->where('cgdNo', $data['cgdNo'])
  378. ->value('orderCode', '');
  379. // //补充收货地址
  380. // $addr = Db::name('order_addr')
  381. // ->field('id,addr,addr_code,contactor,mobile,receipt_quantity')
  382. // ->where(['orderCode' => $data['orderCode'], 'is_del' => 0])
  383. // ->select()
  384. // ->toArray();
  385. // if (!empty($addr)) {
  386. // foreach ($addr as &$vv){
  387. // $temp = explode(',', $vv['addr_code']);
  388. // $temp_ = GetAddr(json_encode(['provice_code' => isset($temp[0]) ? $temp[0] : '', 'city_code' => isset($temp[1]) ? $temp[1] : '', 'area_code' => isset($temp[2]) ? $temp[2] : '']));
  389. // $vv['addr_code'] = $temp_ . $vv['addr'];
  390. // }
  391. // }else
  392. $addr=[];
  393. $data['addr_info'] = $addr;
  394. $data['has_account'] = (int)isset(checkHasAccountBySupplierNos([$data['supplierNo']])[$data['supplierNo']]);
  395. //补充商品创建人字段
  396. $data['good_createrid']=$goon['createrid']??'';
  397. $data['good_creater']=$goon['creater']??'';
  398. return app_show(0, "获取成功", $data);
  399. }
  400. public function edit(){
  401. $cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo']!="" ?trim($this->post['cgdNo']):"";
  402. if($cgdNo==""){
  403. return error_show(1004,"参数cgdNo 不能为空");
  404. }
  405. $data = Db::name("purchease_order")->where(["cgdNo"=>$cgdNo,"is_del"=>0])->find();
  406. if(empty($data)){
  407. return error_show(1004,"未找到数据");
  408. }
  409. $order = ["order_code"=>$cgdNo,"status"=> $data['status'] ,"action_remark"=>$this->post['remark'],"action_type"=>"edit"];
  410. $wsm_code = isset($this->post['wsm_code'])&&$this->post['wsm_code']!=""? trim($this->post['wsm_code']):"";
  411. if($wsm_code!=""){
  412. $ware = Db::name("warehouse_info")->where(["wsm_code"=>$wsm_code,"is_del"=>0])->find();
  413. if(empty($ware)){
  414. return error_show(1004,"未找到仓库信息");
  415. }
  416. // $good = Db::name("good_stock")->where(["wsm_code"=>$wsm_code,"good_type_code"=>$data['good_type_code'],"is_del"=>0])->find();
  417. // if(empty($good)){
  418. // return error_show(1004,"未找到仓库下商品信息");
  419. // }
  420. $data['wsm_code'] = $wsm_code;
  421. }
  422. $cgdid = isset($this->post['cgder_id'])&&$this->post['cgder_id']!=""?intval($this->post['cgder_id']):"";
  423. if($cgdid!=''){
  424. $cgduser = GetInfoById($this->post['token'],["id"=>$cgdid]);
  425. if((!empty($cgduser) && $cgduser['code']!=0) ||empty($cgduser) ){
  426. return error_show($cgduser['code'],$cgduser['message']);
  427. }
  428. $userinfo = $cgduser['data'];
  429. $data['cgder_id'] = $cgdid;
  430. $data['cgder'] = $userinfo['nickname'];
  431. }
  432. $good_num = isset($this->post['good_num'])&&$this->post['good_num']!=""?intval($this->post['good_num']):"";
  433. if($good_num!=""){
  434. $data['good_num'] = $good_num;
  435. }
  436. $good_price = isset($this->post['good_price'])&&$this->post['good_price']!=""?$this->post['good_price']:"";
  437. if($good_price!=""){
  438. $data['good_price'] = $good_price;
  439. }
  440. // $total_fee = isset($this->post['total_fee'])&&$this->post['total_fee']!=""?$this->post['total_fee']:"";
  441. // if($total_fee!=""){
  442. // $data['total_fee'] = $total_fee;
  443. // }
  444. $pakge_fee = isset($this->post['pakge_fee'])&&$this->post['pakge_fee']!=""?$this->post['pakge_fee']:"";
  445. if($pakge_fee!=""){
  446. $data['pakge_fee'] = $pakge_fee;
  447. }
  448. $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!=""?$this->post['cert_fee']:"";
  449. if($cert_fee!=""){
  450. $data['cert_fee'] = $cert_fee;
  451. }
  452. $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!=""?$this->post['open_fee']:"";
  453. if($open_fee!=""){
  454. $data['open_fee'] = $open_fee;
  455. }
  456. $delivery_fee = isset($this->post['delivery_fee'])&&$this->post['delivery_fee']!=""?$this->post['delivery_fee']:"";
  457. if($delivery_fee!=""){
  458. $data['delivery_fee'] = $delivery_fee;
  459. }
  460. $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!=""?$this->post['mark_fee']:"";
  461. if($mark_fee!=""){
  462. $data['mark_fee'] = $mark_fee;
  463. }
  464. $teach_fee = isset($this->post['teach_fee'])&&$this->post['teach_fee']!=""?$this->post['teach_fee']:"";
  465. if($teach_fee!=""){
  466. $data['teach_fee'] = $teach_fee;
  467. }
  468. $nake_fee = isset($this->post['nake_fee'])&&$this->post['nake_fee']!=""?$this->post['nake_fee']:"";
  469. if($nake_fee!=""){
  470. $data['nake_fee'] = $nake_fee;
  471. }
  472. $weight = isset($this->post['weight'])&&$this->post['weight']!=""?$this->post['weight']:"";
  473. if($weight!=""){
  474. $data['weight'] = $weight;
  475. }
  476. $diff_weight = isset($this->post['diff_weight'])&&$this->post['diff_weight']!=""?$this->post['diff_weight']:"";
  477. if($diff_weight!=""){
  478. $data['diff_weight'] = $diff_weight;
  479. }
  480. $diff_fee = isset($this->post['diff_fee'])&&$this->post['diff_fee']!=""?$this->post['diff_fee']:"";
  481. if($diff_fee!=""){
  482. $data['diff_fee'] = $diff_fee;
  483. }
  484. $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""?trim($this->post['supplierNo'])
  485. :"";
  486. if($supplierNo!=""){
  487. $userCommon = new \app\admin\common\User();
  488. $supplier_temp = $userCommon->handle('getCodeAndName', ['code' => $supplierNo]);
  489. // $supplier =Db::name("supplier")->where(['code'=>$supplierNo])->find();
  490. if($supplier_temp['code']!=0 || empty($supplier_temp['data']) ) return error_show(1004,"未找到供应商信息");
  491. // if(empty($supplier)){
  492. // return error_show(1004,"未找到供应商信息");
  493. // }
  494. $data['supplierNo'] = $supplierNo;
  495. $data['supplier_name'] = $supplier_temp['data'][$supplierNo]??"";
  496. }
  497. $remark = isset($this->post['remark'])&&$this->post['remark']!=""?trim($this->post['remark']):"";
  498. if($remark!=""){
  499. $data['remark'] = $remark;
  500. }
  501. $data['good_price'] = round(($data['pakge_fee']+$data['weight']*$data['gold_price']+$data['nake_fee']+$data['mark_fee']+$data['cert_fee']+$data['open_fee']/$data['good_num']+$data['teach_fee']*$data['weight']+$data['delivery_fee']),2);
  502. $data['total_fee'] = round($data['good_price']*$data['good_num'],2);
  503. $data['updatetime'] =date("Y-m-d H:i:s");
  504. $upd=Db::name("purchease_order")->save($data);
  505. if($upd){
  506. // ActionLog::logAdd($this->post['token'],$order,'cgd',$data['status'],$this->post);
  507. //修改状态,添加待办
  508. ActionLog::logAdd($this->post['token'], $order, "CGD", $data['status'], $this->post);
  509. // ProcessOrder::AddProcess($this->post['token'], [
  510. // "order_type" => 'CGD',
  511. // "order_code" => $cgdNo,//销售单code
  512. // "order_id" => $data['id'],
  513. // "order_status" => $data['status'],"before_status"=>1
  514. // ]);
  515. return app_show(0,"更新成功");
  516. }else{
  517. return error_show(1004,'更新失败');
  518. }
  519. }
  520. //修改采购单
  521. public function editNew()
  522. {
  523. $param = $this->request->only(['cgdNo', 'supplierNo', 'token', 'wsm_code' => ''], 'post', 'trim');
  524. $val = Validate::rule([
  525. 'cgdNo|采购单号' => 'require',
  526. 'supplierNo|供应商编号' => 'require',
  527. 'token' => 'require',
  528. ]);
  529. if (!$val->check($param)) return error_show(1004, $val->getError());
  530. Db::startTrans();
  531. try {
  532. $rs = Db::name('purchease_order')
  533. ->alias('po')
  534. ->field('po.id,po.order_type,po.order_source,po.status,po.cgder_id,po.cgder,po.supplierNo,po.supplier_name,po.wsm_code,wi.name wsm_name')
  535. ->leftJoin('warehouse_info wi', 'wi.wsm_code=po.wsm_code AND wi.is_del=0')
  536. ->where([
  537. 'po.cgdNo' => $param['cgdNo'],
  538. 'po.is_del' => 0,
  539. 'po.status' => 0
  540. ])->find();
  541. if (empty($rs)) throw new Exception('采购单不存在或不允许修改');
  542. $update = ['updatetime' => date('Y-m-d H:i:s')];
  543. //order_type==1备库
  544. if ($rs['order_type'] == 1 && $rs['order_source']==0) {
  545. if (empty($param['wsm_code'])) throw new Exception('备库单请传入仓库编码');
  546. else {
  547. $wsm_rs = Db::name('warehouse_info')
  548. ->field('id,wsm_code,name wsm_name')
  549. ->where([
  550. 'wsm_code' => $param['wsm_code'],
  551. 'is_del' => 0,
  552. ])->find();
  553. if (empty($wsm_rs)) throw new Exception('查不到该仓库的记录');
  554. else $update['wsm_code'] = $wsm_rs['wsm_code'];
  555. }
  556. }
  557. //供应商信息
  558. // $supplier_rs = Db::name('supplier')
  559. // ->field('id,name supplierName,code supplierNo,person,personid')
  560. // ->where(['is_del' => 0, 'code' => $param['supplierNo']])
  561. // ->find();
  562. $userCommon= new \app\admin\common\User();
  563. $supplier_temp =$userCommon->handle("sInfo",["code"=>$param['supplierNo']]);
  564. if ($supplier_temp['code']!=0 || empty($supplier_temp['data'])) throw new Exception('查不到该供应商的记录');
  565. else {
  566. $supplier_rs=$supplier_temp['data'];
  567. $update['cgder_id'] = $supplier_rs['personid'];
  568. $update['cgder'] = $supplier_rs['person'];
  569. $update['supplierNo'] = $supplier_rs['code'];
  570. $update['supplier_name'] = $supplier_rs['name'];
  571. }
  572. //是否修改内容确定
  573. if (isset($update['wsm_code'])) {
  574. if ($update['wsm_code'] == $rs['wsm_code'] && $update['supplierNo'] == $rs['supplierNo']) throw new Exception('没有修改的内容,不能提交');
  575. } elseif ($update['supplierNo'] == $rs['supplierNo']) throw new Exception('没有修改的内容,不能提交');
  576. if ($update['supplierNo'] == $rs['supplierNo'] && $param['wsm_code'] == $rs['wsm_code']) throw new Exception('没有修改的内容');
  577. //修改
  578. Db::name('purchease_order')
  579. ->where([
  580. 'id' => $rs['id'],
  581. 'is_del' => 0,
  582. 'status' => 0
  583. ])->update($update);
  584. $user = GetUserInfo($param['token']);
  585. $creater_id = isset($user['data']['id']) ? $user['data']['id'] : 0;
  586. $creater = isset($user['data']['nickname']) ? $user['data']['nickname'] : '';
  587. //添加修改记录
  588. Db::name('purchease_change_supplier_log')
  589. ->insert([
  590. 'cgdNo' => $param['cgdNo'],
  591. 'cgder_id_old' => $rs['cgder_id'],
  592. 'cgder_id' => $update['cgder_id'],
  593. 'cgder_old' => $rs['cgder'],
  594. 'cgder' => $update['cgder'],
  595. 'supplierNo_old' => $rs['supplierNo'],
  596. 'supplierNo' => $update['supplierNo'],
  597. 'supplier_name_old' => $rs['supplier_name'],
  598. 'supplier_name' => $update['supplier_name'],
  599. 'wsm_code_old' => $rs['wsm_code'],
  600. 'wsm_code' => isset($update['wsm_code']) ? $update['wsm_code'] : $rs['wsm_code'],
  601. 'wsm_name_old' => $rs['wsm_name'],
  602. 'wsm_name' => isset($wsm_rs['wsm_name']) ? $wsm_rs['wsm_name'] : $rs['wsm_name'],
  603. 'addtime' => date('Y-m-d H:i:s'),
  604. 'updatetime' => date('Y-m-d H:i:s'),
  605. 'creater_id' => $creater_id,
  606. 'creater' => $creater,
  607. ]);
  608. //记录日志
  609. ActionLog::logAdd(['id' => $creater_id, 'nickname' => $creater], $rs, "CGD", $rs['status'], $param);
  610. // ProcessOrder::AddProcess($this->post['token'], [
  611. // "order_type" => 'CGD',
  612. // "order_code" => $param['cgdNo'],//销售单code
  613. // "order_id" => $rs['id'],
  614. // "order_status" => $rs['status']
  615. // ]);
  616. //维护台账
  617. Db::name('standing_book')
  618. ->where('cgdNo', $param['cgdNo'])
  619. ->update(['supplierNo' => $param['supplierNo'], 'updatetime' => date('Y-m-d H:i:s')]);
  620. Db::commit();
  621. return app_show(0, '修改成功');
  622. } catch (Exception $exception) {
  623. Db::rollback();
  624. return error_show(1005, $exception->getMessage());
  625. }
  626. }
  627. public function status()
  628. {
  629. $cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo'] != "" ? $this->post['cgdNo'] : [];
  630. if (empty($cgdNo)) {
  631. return error_show(1004, "参数cgdNo 不能为空");
  632. }
  633. $remark = isset($this->post['remark']) && $this->post['remark'] != "" ? trim($this->post['remark']) : "";
  634. $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
  635. if ($status === "") {
  636. return error_show(1004, "参数status 不能为空");
  637. }
  638. Db::startTrans();
  639. try {
  640. if ($status == 0) {
  641. $data = Db::name("purchease_order")
  642. ->field('id,cgdNo,spuCode')
  643. ->whereIn('cgdNo', $cgdNo)
  644. ->where(["is_del" => 0])
  645. ->where('send_status', '>', 1)
  646. ->find();
  647. if (!empty($data)) throw new Exception($data['cgdNo'] . "采购单发货中无法取消");
  648. }
  649. // if($data['send_status']>1 && $status==0){
  650. // return error_show(1004,"采购单发货中无法取消");
  651. // }
  652. // $order = ["order_code"=>$cgdNo,"status"=> $data['status'] ,"action_remark"=>$remark,"action_type"=>"status"];
  653. // $data['status'] = $status;
  654. // $data['remark'] = $remark;
  655. // $data['updatetime'] =date("Y-m-d H:i:s");
  656. //原始数据
  657. $info = Db::name("purchease_order")
  658. ->whereIn('cgdNo', $cgdNo)
  659. ->column('id,cgdNo,status,supplierNo,spuCode,order_type', 'cgdNo');
  660. $upd = Db::name("purchease_order")
  661. ->whereIn('cgdNo', $cgdNo)
  662. ->save([
  663. 'status' => $status,
  664. 'remark' => $remark,
  665. 'updatetime' => date("Y-m-d H:i:s"),
  666. ]);
  667. if ($upd) {
  668. //获取供应商的负责人
  669. $userCommon = new \app\admin\common\User();
  670. $supplier = $userCommon->handle('sGetList',['more_code'=>array_column($info, 'supplierNo')]);
  671. $supplier_cgderid = array_column($supplier['data']['list'],'personid','code');
  672. // $supplier_cgderid = Db::name('supplier')
  673. // ->where('is_del', 0)
  674. // ->whereIn('code', array_column($info, 'supplierNo'))
  675. // ->column('personid', 'code');
  676. // ->leftJoin('supplier sip', 'sip.code=po.supplierNo')
  677. // ->field('po.*,on.orderCode,u.itemid,sip.personid as supplier_cgderid,sip.person as supplier_cgder')
  678. // $user=GetUserInfo($this->post['token']);
  679. $uid = $this->uid;
  680. $uname = $this->uname;
  681. foreach ($cgdNo as $vlue) {
  682. $isreturn = cgd_sale_return($vlue);
  683. if($isreturn){
  684. throw new Exception("{$vlue}关联销售单存在退货单正在进行");
  685. }
  686. if($status == 1){
  687. if($this->level == 2 && $uid != $supplier_cgderid[$info[$vlue]['supplierNo']]) throw new Exception('只能由供应商负责人来操作');//与供应商确认的这个操作,只能由供应商负责人来操作
  688. }
  689. if ($status == 1 || $status == 2) {
  690. // $orderinfo = Db::name('sale')
  691. // ->alias('a')
  692. // ->field('a.id,a.orderCode,a.is_stock,a.order_type,a.cgderid')
  693. // ->leftJoin('order_num b','b.orderCode=a.orderCode')
  694. // ->where([
  695. // 'a.is_del'=>0,
  696. // 'b.cgdNo'=>$vlue,
  697. // ])->findOrEmpty();
  698. // $is_stock = Db::name('good_basic')
  699. // ->where(['is_del' => 0, 'spuCode' => $info[$vlue]['spuCode']])
  700. // ->value('is_stock');
  701. // if ($is_stock == 1) {
  702. // //库存品,推给31库管人员、41库管-张凯旋
  703. // $uids = Db::name('user_role')
  704. // ->where([
  705. // ['is_del', '=', 0],
  706. // ['roleid', 'in', [31, 41]],
  707. // ['status', '=', 1]
  708. // ])->column('uid');
  709. //// if (!in_array($this->uid, $uids)) throw new Exception('库存品订单只能由库管人员操作');
  710. // $process = ["order_code" => $vlue, "order_id" => isset($info[$vlue]['id']) ? $info[$vlue]['id'] : 0, "order_status" => $status, "order_type" => 'CGD', "before_status" => isset($info[$vlue]['status']) ? $info[$vlue]['status'] : 0, 'holder_id' => isset($supplier_cgderid[$info[$vlue]['supplierNo']]) ? $supplier_cgderid[$info[$vlue]['supplierNo']] : 0, 'handle_user_list' => implode(',', $uids)];
  711. // } elseif ($is_stock == 0 || $info[$vlue]['order_type'] == 3) {
  712. //非库存品和采返商品,推给供应商负责人
  713. // if ($this->uid != $supplier_cgderid[$info[$vlue]['supplierNo']]) throw new Exception('非库存品和采返商品只能由供应商负责人操作');
  714. $process = ["order_code" => $vlue, "order_id" => isset($info[$vlue]['id']) ? $info[$vlue]['id'] : 0, "order_status" => $status, "order_type" => 'CGD', "before_status" => isset($info[$vlue]['status']) ? $info[$vlue]['status'] : 0, 'holder_id' => isset($supplier_cgderid[$info[$vlue]['supplierNo']]) ? $supplier_cgderid[$info[$vlue]['supplierNo']] : 0, 'handle_user_list' => isset($supplier_cgderid[$info[$vlue]['supplierNo']]) ? $supplier_cgderid[$info[$vlue]['supplierNo']] : 0];
  715. // }
  716. } else $process = ["order_code" => $vlue, "order_id" => isset($info[$vlue]['id']) ? $info[$vlue]['id'] : 0, "order_status" => $status, "order_type" => 'CGD', "before_status" => isset($info[$vlue]['status']) ? $info[$vlue]['status'] : 0, 'holder_id' => isset($supplier_cgderid[$info[$vlue]['supplierNo']]) ? $supplier_cgderid[$info[$vlue]['supplierNo']] : 0];
  717. ProcessOrder::AddProcess(['id' => $uid, 'nickname' => $uname], $process);
  718. $order = ["order_code" => $vlue, "status" => '', "action_remark" => $remark, "action_type" => "status"];
  719. ActionLog::logAdd(['id' => $uid, 'nickname' => $uname], $order, 'CGD', $status, $this->post);
  720. }
  721. // return app_show(0, "更新成功");
  722. } else throw new Exception('更新失败');
  723. // return error_show(1004, '更新失败');
  724. Db::commit();
  725. return app_show(0, "更新成功");
  726. } catch (Exception $exception) {
  727. Db::rollback();
  728. return error_show(1004, '更新失败,' . $exception->getMessage());
  729. }
  730. }
  731. //创建采购工差单
  732. public function diffcreat(){
  733. $token = isset($this->post['token']) && $this->post['token'] !=="" ?trim($this->post['token']):"";
  734. //$cgdNo=makeNo("CG");
  735. $cgdNo = $this->post['cgdNo'] && $this->post['cgdNo'] !=="" ? trim($this->post['cgdNo']) :"";
  736. if($cgdNo==""){
  737. return error_show(1002,"参数good_code不能为空");
  738. }
  739. $cg = Db::name('purchease_order')->where(['cgdNo'=>$cgdNo,'is_del'=>0])->find();
  740. if($cg==""){
  741. return error_show(1002,"未找到采购单数据");
  742. }
  743. if($cg['order_type']==3){
  744. $gd = Db::name("good_zixun")->where(["spuCode"=>$cg['spuCode']])->find();
  745. }else {
  746. $gd =Db::name('good_basic')->where(['spuCode'=>$cg['spuCode']])->find();
  747. }
  748. if($gd==""){
  749. return error_show(1002,"未找到商品数据");
  750. }
  751. $diff_weight = isset($this->post['diff_weight']) && $this->post['diff_weight'] !=="" ? floatval($this->post['diff_weight']) :"";
  752. if($diff_weight===""){
  753. return error_show(1002,"参数diff_weight不能为空");
  754. }
  755. // $apply_id =GetUserInfo($token);
  756. // if(empty($apply_id)||$apply_id['code']!=0){
  757. // return error_show(1002,"申请人数据不存在");
  758. // }
  759. $rid= $this->uid;
  760. $rname= $this->uname;
  761. $diff_price = round($diff_weight*$cg['gold_price']+$diff_weight*$cg['teach_fee'],2);
  762. //如果有未处理的工差单,不允许创建新的
  763. $wait_check = Db::name('purchease_diff')
  764. ->field('id')
  765. ->where(['apply_id'=>$rid,'status'=>1,'is_del'=>0,"cgdNo"=>$cgdNo])
  766. ->find();
  767. if(!empty($wait_check)) return error_show('1005','您还有未处理的工差单,请先处理');
  768. $data=[
  769. "cgdNo"=>$cgdNo,
  770. "good_code"=>$cg['spuCode'],
  771. "good_name"=>$cg['good_name'],
  772. "sale_price"=>$cg['good_price'],
  773. "good_weight"=>$cg['weight']*$cg['good_num'],
  774. "good_num"=>$cg['good_num'],
  775. "apply_id"=>$rid,
  776. "apply_name"=>$rname,
  777. "diff_weight"=>$diff_weight,
  778. "diff_price"=>$diff_price,
  779. "gold_price"=>$cg['good_price'],
  780. "status"=>1,
  781. "is_del"=>0,
  782. "addtime"=>date("Y-m-d H:i:s"),
  783. "updatetime"=>date("Y-m-d H:i:s")
  784. ];
  785. Db::startTrans();
  786. try{
  787. $item = Db::name("purchease_diff")->insert($data,true);
  788. if($item>0){
  789. $sto = ["order_code"=>$cgdNo,"status"=>1,"action_remark"=>'',"action_type"=>"create"];
  790. ActionLog::logAdd(['id'=>$rid,'nickname'=>$rname],$sto,"CGGCD",1,$data);
  791. $process=["order_code"=>$cgdNo,"order_id"=>$item,"order_status"=>1,"order_type"=>'CGGCD',"before_status"=>1,'holder_id'=>$rid];
  792. ProcessOrder::AddProcess(['id'=>$rid,'nickname'=>$rname],$process);
  793. $update_standing_book_data = [
  794. 'cgd_diff_id' => $item,//采购工差单id
  795. 'updatetime' => date("Y-m-d H:i:s")
  796. ];
  797. $orderCode = Db::name("order_num")->where([["cgdNo","=",$cg['cgdNo']],["status","=",1]])->find();
  798. if($orderCode!=false){
  799. $order = Db::name("sale")->where("orderCode", '=', $orderCode['orderCode'])->find();
  800. if($order==false){
  801. Db::rollback();
  802. return error_show(1002,"未找到确认单信息");
  803. }
  804. $data=[
  805. "cgd_diffid"=>$item,
  806. "orderCode"=>$orderCode['orderCode'],
  807. "good_code"=>$cg['spuCode'],
  808. "good_name"=>$cg['good_name'],
  809. "diff_weight"=>$diff_weight,
  810. "diff_price"=>round($diff_weight*$order['gold_price']+$diff_weight*$order['cost_price'],2),
  811. "gold_price"=>$order['sale_price'],
  812. "status"=>1,
  813. "addtime"=>date("Y-m-d H:i:s"),
  814. "updatetime"=>date("Y-m-d H:i:s")
  815. ];
  816. $cgd = Db::name('sale_diff')->insert($data,true);
  817. if($cgd==0){
  818. // $sto = ["order_code"=>$cg['bkcode'],"status"=>1,"action_remark"=>'',"action_type"=>"create"];
  819. // ActionLog::logAdd($this->post['token'],$sto,"ZXGCD",1,$sto);
  820. // $process=["order_code"=>$cg['bkcode'],"order_id"=>$cgd,"order_status"=>1,"order_type"=>'ZXGCD'];
  821. // ProcessOrder::AddProcess($this->post['token'],$process);
  822. // Db::commit();
  823. // return error_show(0,"新建成功");
  824. // }else{
  825. Db::rollback();
  826. return error_show(1002,"新建失败");
  827. }
  828. $sto = ["order_code"=>$orderCode['orderCode'],"status"=>1,"action_remark"=>'',"action_type"=>"create"];
  829. ActionLog::logAdd($this->post['token'],$sto,"XSGCD",1,$data);
  830. $process=["order_code"=>$orderCode['orderCode'],"order_id"=>$cgd,"order_status"=>1,"order_type"=>'XSGCD',"before_status"=>1,'holder_id'=>$order['apply_id']];
  831. ProcessOrder::AddProcess($this->post['token'],$process);
  832. $update_standing_book_data['sale_diff_id']=$cgd;//工差单id
  833. }
  834. //维护台账记录
  835. Db::name('standing_book')
  836. ->where('cgdNo', $cgdNo)
  837. ->update($update_standing_book_data);
  838. Db::commit();
  839. return error_show(0,"新建成功");
  840. }else{
  841. Db::rollback();
  842. return error_show(1002,"新建失败");
  843. }
  844. }catch (\Exception $e){
  845. Db::rollback();
  846. return error_show(1002,$e->getMessage());
  847. }
  848. }
  849. public function difflist(){
  850. $page = isset($this->post['page']) && $this->post['page'] !==""? intval($this->post['page']):"1";
  851. $size = isset($this->post['size']) && $this->post['size'] !==""? intval($this->post['size']):"10";
  852. $where = [['a.is_del',"=",0]];
  853. $cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo']!="" ? trim($this->post['cgdNo']):"";
  854. if($cgdNo!=""){
  855. $where[]=['a.cgdNo',"like", "%$cgdNo%"];
  856. }
  857. $status = isset($this->post['status']) && $this->post['status'] !==""? intval($this->post['status']):"";
  858. if($status!==""){
  859. $where[]=['a.status',"=",$status];
  860. }
  861. $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
  862. if ($start !="") {
  863. $where[]= ["a.addtime",'>=',$start];
  864. }
  865. $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
  866. if($end !=""){
  867. $where[]= ["a.addtime",'<=',$end];
  868. }
  869. $apply_name = isset($this->post['apply_name']) && $this->post['apply_name'] !==""? intval($this->post['apply_name']):"";
  870. if($apply_name!==""){
  871. $where[]=['a.apply_name',"like","%$apply_name%"];
  872. }
  873. $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
  874. if ($company_name !== "") $where[] = ["a.apply_id", 'in', get_company_item_user_by_name($company_name)];
  875. // $role = $this->checkDataShare();
  876. // if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['a.apply_id', 'in', $role[DataGroupModel::$type_全部]];
  877. $role = $this->checkDataShare();
  878. $hand = resign_hand_user($this->uid,0);
  879. if (!empty($role[DataGroupModel::$type_全部])) {
  880. $arr= array_unique(array_merge($hand,$role[DataGroupModel::$type_全部]));
  881. $where[] = ['a.apply_id', 'in',$arr];
  882. }
  883. $count = Db::name('purchease_diff')
  884. ->alias('a')
  885. ->join("good b","b.spuCode=a.good_code","left")
  886. ->where($where)
  887. ->count();
  888. $total = ceil($count/$size);
  889. $page = $page >= $total ? $total : $page;
  890. $list = Db::name('purchease_diff')
  891. ->alias('a')
  892. ->join("good b","b.spuCode=a.good_code","left")
  893. ->where($where)
  894. ->page($page,$size)
  895. ->order("a.addtime desc")
  896. ->field("a.*,b.cat_id")
  897. ->select()
  898. ->toArray();
  899. $all_createrid = array_column($list,'apply_id');
  900. $item = get_company_name_by_uid($all_createrid);
  901. $data=[];
  902. foreach ($list as $value){
  903. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  904. $value['company_name'] = $item[$value['apply_id']]??'';
  905. //是否具有编辑权限
  906. $value['is_allow_update'] = 0;
  907. if (in_array($this->roleid, [1, 33]) || in_array($value['apply_id'], $role[DataGroupModel::$type_可编辑])) $value['is_allow_update'] = 1;
  908. $data[]=$value;
  909. }
  910. return app_show(0,"获取成功",['list'=>$data,'count'=>$count]);
  911. }
  912. public function diffinfo(){
  913. $id = isset($this->post['id']) && $this->post['id'] !=="" ? trim($this->post['id']) :"";
  914. if($id==""){
  915. return error_show(1002,"参数id 不能为空");
  916. }
  917. $idinf = Db::name('purchease_diff')->where(['id'=>$id,'is_del'=>0])->find();
  918. if($idinf==false){
  919. return error_show(1002,"未找到采购工差单数据");
  920. }
  921. $dn = Db::name('purchease_order')->where(['cgdNo'=>$idinf['cgdNo'],'is_del'=>0])->find();
  922. if($dn['order_type']==3){
  923. $goon = Db::name("good_zixun")->where(["spuCode"=>$dn['spuCode'],"is_del"=>0])->find();
  924. }else {
  925. $goon =Db::name('good_basic')->where(['spuCode'=>$dn['spuCode']])->find();
  926. }
  927. // $goon = Db::name('good')->where(['spuCode'=>$idinf['good_code']])->find();
  928. if(empty($goon)){
  929. return error_show(1002,"未找到商品数据");
  930. }
  931. $idinf['wsm_name'] ="";
  932. $idinf['wsm_supplier'] ="";
  933. $idinf['wsm_supplierNo'] ="";
  934. $idinf['wsm_contactor'] ="";
  935. $idinf['wsm_mobile'] ="";
  936. $idinf['addr_code'] ="";
  937. $idinf['wsm_addr'] ="";
  938. if($dn['wsm_code']!=""){
  939. $wsmcode = Db::name("warehouse_info")->alias("a")->leftJoin("supplier b","a.supplierNo=b.code")
  940. ->leftJoin("warehouse_addr c","a.wsm_code=c.wsm_code and c.is_del=0")
  941. ->where(["a.wsm_code"=>$dn['wsm_code']])->field("a.name as wsm_name,b.name,b.code,c.wsm_name as wsm_contactor,c.wsm_mobile,c.wsm_addr,c.addr_code")->find();
  942. $idinf['wsm_name'] =isset($wsmcode['wsm_name']) ? $wsmcode['wsm_name']:"";
  943. $idinf['wsm_supplier'] =isset($wsmcode['name']) ? $wsmcode['name']:"";
  944. $idinf['wsm_supplierNo'] =isset($wsmcode['code']) ? $wsmcode['code']:"";
  945. $idinf['wsm_contactor'] =isset($wsmcode['wsm_contactor']) ? $wsmcode['wsm_contactor']:"";
  946. $idinf['wsm_mobile'] =isset($wsmcode['wsm_mobile']) ? $wsmcode['wsm_mobile']:"";
  947. $idinf['addr_code'] =isset($wsmcode['addr_code']) ? $wsmcode['addr_code']:"";
  948. $idinf['addr_cn'] =isset($wsmcode['addr_code']) ? GetAddr($wsmcode['addr_code']):"";
  949. $idinf['wsm_addr']=isset($wsmcode['wsm_addr']) ? $wsmcode['wsm_addr']:"";
  950. }
  951. $idinf['info'] =$dn;
  952. $int= isset($goon['cat_id']) && $goon['cat_id'] !=0 ? made($goon['cat_id']):[];
  953. $idinf['can']=$int;
  954. $idinf['order_type']=$dn['order_type'];
  955. $idinf['order_source']=$dn['order_source'];
  956. //取出销售的工差单信息
  957. $diff = Db::name('sale_diff')->field('id,customer_remark,is_act,remark')->where('cgd_diffid',$id)->find();
  958. $idinf['diff_customer_remark']=$diff['customer_remark'];
  959. $idinf['diff_is_act']=$diff['is_act'];
  960. $idinf['diff_remark']=$diff['remark'];
  961. return app_show(0,"获取成功",$idinf);
  962. }
  963. public function diffstatu(){
  964. $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
  965. if($id==""){
  966. return error_show(1002,"参数id不能为空");
  967. }
  968. $dio = Db::name('purchease_diff')->where(['id'=>$id,'is_del'=>0])->find();
  969. if(empty($dio)){
  970. return error_show(1002,"工差订单未找到");
  971. }
  972. $cgd = Db::name("purchease_order")->where(['cgdNo'=>$dio['cgdNo']])->find();
  973. if(empty($cgd)){
  974. return error_show(1002,"采购单未找到");
  975. }
  976. $salediff=Db::name("sale_diff")->where(["cgd_diffid"=>$dio['id']])->find();
  977. if($salediff==false){
  978. return error_show(1002,"销售工差单未找到");
  979. }
  980. $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"";
  981. if($status===""){
  982. return error_show(1002,"参数status不能为空");
  983. }
  984. Db::startTrans();
  985. try{
  986. $temp = $dio['status'];
  987. $dio['status']=$status;
  988. $dio['updatetime']=date("Y-m-d H:i:s");
  989. $item = Db::name("purchease_diff")->save($dio);
  990. if ($item){
  991. if($status==2){
  992. $cgd['diff_fee'] =$dio['diff_price'];
  993. $cgd['diff_weight'] =$dio['diff_weight'];
  994. $cgd['updatetime'] =date("Y-m-d H:i:s");
  995. $cgp=Db::name("purchease_order")->save($cgd);
  996. if($cgp==false){
  997. Db::rollback();
  998. return error_show(1002,"采购单更新失败");
  999. }
  1000. if($salediff['is_act']==1){
  1001. $saled=[
  1002. "diff_fee"=>$salediff['diff_price'],
  1003. "diff_weight"=>$salediff['diff_weight'],
  1004. "updatetime"=>date("Y-m-d H:i:s")
  1005. ];
  1006. $up =Db::name("sale")->where(["orderCode"=>$salediff['orderCode']])->save($saled);
  1007. if($up==false){
  1008. Db::rollback();
  1009. return error_show(1002,"销售单更新失败");
  1010. }
  1011. }
  1012. }
  1013. $sto = ["order_code" => $dio['cgdNo'], "status" => 1, "action_remark" => '', "action_type" => "create"];
  1014. ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], $sto, "CGGCD", $status, $this->post);
  1015. $process = ["order_code" => $dio['cgdNo'], "order_id" => $dio['id'], "order_status" => $status, "order_type" => 'CGGCD', "before_status" => 1, 'holder_id' => $dio['apply_id']];
  1016. ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname], $process);
  1017. Db::commit();
  1018. return error_show(0,"更新成功");
  1019. }else{
  1020. Db::rollback();
  1021. return error_show(1002,"更新失败");
  1022. }
  1023. }catch (\Exception $e){
  1024. Db::rollback();
  1025. return error_show(1002,$e->getMessage()."|".$e->getLine());
  1026. }
  1027. }
  1028. //修改采购单的实时金价
  1029. public function editGoldPrice()
  1030. {
  1031. $param = $this->request->only(['cgdNo', 'gold_price'], 'post', 'trim');
  1032. $val = Validate::rule(['cgdNo|采购单号' => 'require', 'gold_price|实时金价' => 'require|float']);
  1033. if (!$val->check($param)) return error_show(1004, $val->getError());
  1034. //采购单
  1035. $data = Db::name("purchease_order")
  1036. ->field('id,demo_fee,good_num,weight,open_fee,teach_fee,pakge_fee,mark_fee,cert_fee,nake_fee,delivery_fee,status')
  1037. ->where(["cgdNo" => $param['cgdNo'], "is_del" => 0])
  1038. ->find();
  1039. if (empty($data)) return error_show(1004, "未找到该采购单数据");
  1040. if ($data['status'] != 0) return error_show(1005, '该状态下不允许修改实时金价');
  1041. $sale_price = round($data['demo_fee'] / $data['good_num'] + $data['open_fee'] / $data['good_num'] +$data['weight'] * $param["gold_price"] + $data['teach_fee'] * $data['weight'] +
  1042. $data['pakge_fee'] + $data['mark_fee'] + $data['cert_fee'] +$data['nake_fee'] + $data['delivery_fee'],2);
  1043. $total_price = round($data['good_num']*$sale_price,2);
  1044. $rs = Db::name("purchease_order")
  1045. ->where('id', $data['id'])
  1046. ->update(['updatetime' => date('Y-m-d H:i:s'), 'gold_price' => $param['gold_price'],"good_price"=>$sale_price,"total_fee"=>$total_price]);
  1047. return $rs ? app_show(0, '修改采购单实时金价成功') : error_show(1005, '修改采购单实时金价失败');
  1048. }
  1049. //采购单导出
  1050. public function exportCgdList()
  1051. {
  1052. $cgdNos = $this->request->post('cgdNos', [], 'trim');
  1053. if (empty($cgdNos)) return error_show(1004, '要导出的采购单编号不能为空');
  1054. $i = 1;
  1055. $send_type = [1 => '直接发货', 2 => '延时发货'];
  1056. $status = [0 => '待与供应商确认', 1 => '待入库', 2 => '部分入库', 3 => '入库完成', 4 => '已取消订单'];
  1057. $list = Db::name("purchease_order")
  1058. ->alias('po')
  1059. ->field('"" as 序号,po.addtime as 创建时间,po.cgdNo as 采购单编号,po.status as 采购单状态,po.cgder as 采购员,s.orderCode as 确认单号,s.addtime as 确认单时间,po.spuCode as 产品编号,po.good_name as 产品名称,"" as 规格,"" as 单位,po.supplier_name as 供应商名称,po.supplierNo as 供应商编号,po.nake_fee as 裸价,po.delivery_fee as 物流费,s.send_type as 发货方式,po.good_price as 采购单价,s.remark as 确认单备注,po.good_num as 采购数量,po.total_fee as 采购货款,"" as 购买方公司,s.arrive_time as 到货时间,"" 税率,oa.addr 收货地址,oa.mobile 电话,oa.contactor 联系人,s.platform_order 平台订单编号,oa.receipt_quantity 地址发货数量, oa.addr_code,po.order_type,s.supplierNo')
  1060. ->whereIn('po.cgdNo', $cgdNos)
  1061. ->leftJoin('order_num on', 'on.cgdNo=po.cgdNo')
  1062. ->leftJoin('sale s', 's.orderCode=on.orderCode AND s.is_del=0')
  1063. ->leftJoin('order_addr oa', 'oa.orderCode=on.orderCode AND oa.is_del=0')
  1064. // ->leftJoin('business b', 'b.companyNo=s.supplierNo AND b.is_del=0')
  1065. ->order("po.addtime desc")
  1066. ->withAttr('序号', function () use (&$i) {
  1067. return $i++;
  1068. })->withAttr('采购单状态', function ($val) use ($status) {
  1069. return isset($status[$val]) ? $status[$val] : '';
  1070. })->withAttr('发货方式', function ($val) use ($send_type) {
  1071. return isset($send_type[$val]) ? $send_type[$val] : '';
  1072. })->withAttr('发货方式', function ($val) use ($send_type) {
  1073. return isset($send_type[$val]) ? $send_type[$val] : '';
  1074. })
  1075. ->select()
  1076. ->toArray();
  1077. $all_supplierNo = array_column($list, 'supplierNo');
  1078. $userCommon = new \app\admin\common\User();
  1079. $tmp = $userCommon->handle('getCodeAndName', ['code' => $all_supplierNo]);
  1080. foreach ($list as &$value) {
  1081. if ($value['order_type'] == 3) {
  1082. $temp = Db::name("good_zixun")
  1083. ->where(["spuCode" => $value['产品编号'], "is_del" => 0])
  1084. ->field('id,specinfo,good_unit,tax')
  1085. ->find();
  1086. $good_unit = isset($temp['good_unit']) ? $temp['good_unit'] : 0;
  1087. $specinfo = isset($temp['specinfo']) ? json_decode($temp['specinfo'], true) : [];
  1088. $speclist = [];
  1089. foreach ($specinfo as $val) {
  1090. $speclist[] = $val['spec_name'] . ':' . $val['spec_value_name'];
  1091. }
  1092. $value['税率'] = $temp['tax'] . '%';
  1093. } else {
  1094. $good_unit = Db::name('good_basic')
  1095. ->field('id,good_unit,tax')
  1096. ->where(['spuCode' => $value['产品编号']])
  1097. ->find();
  1098. $spec = Db::name("good_spec")
  1099. ->field('id,spec_id,spec_value_id')
  1100. ->where(["spuCode" => $value['产品编号'], "is_del" => 0])
  1101. ->select()
  1102. ->toArray();
  1103. $speclist = [];
  1104. if (!empty($spec)) {
  1105. foreach ($spec as $val) {
  1106. $speclist[] = Db::name("specs")->where(["id" => $val['spec_id']])->value('spec_name', '') . ':' . Db::name("spec_value")->where(["id" => $val['spec_value_id']])->value('spec_value', '');
  1107. }
  1108. }
  1109. $value['税率'] = isset($good_unit['tax']) ? $good_unit['tax'] . '%' : '';
  1110. }
  1111. $value['规格'] = empty($speclist) ? '' : implode(',', $speclist);;
  1112. $value['单位'] = isset($good_unit['good_unit']) ? Db::name('unit')->where(['id' => $good_unit['good_unit'], 'is_del' => 0])->value('unit', '') : '';
  1113. if (!empty($value['addr_code'])) {
  1114. $temp = explode(',', $value['addr_code']);
  1115. $temp_ = GetAddr(json_encode(['provice_code' => $temp[0], 'city_code' => $temp[1], 'area_code' => $temp[2]]));
  1116. $value['收货地址'] = $temp_ . $value['收货地址'];
  1117. }
  1118. $value['购买方公司'] = $tmp['data'][$value['supplierNo']] ?? '';
  1119. unset($value['addr_code']);
  1120. unset($value['order_type']);
  1121. unset($value['supplierNo']);
  1122. }
  1123. $headerArr = array_keys($list[0]);
  1124. excelSave('采购单导出' . date('YmdHis'), $headerArr, $list);
  1125. }
  1126. //获取采购单修改供应商的记录列表
  1127. public function getChangeSupplierList()
  1128. {
  1129. $param = $this->request->only(['cgdNo' => '', 'start' => '', 'end' => '', 'creater' => '', 'page' => 1, 'size' => 15, 'company_name' => ''], 'post', 'trim');
  1130. $where = [['a.is_del', '=', 0]];
  1131. if (!empty($param['cgdNo'])) $where[] = ['a.cgdNo', 'like', '%' . $param['cgdNo'] . '%'];
  1132. if (!empty($param['start'])) $where[] = ['a.addtime', '>=', $param['start']];
  1133. if (!empty($param['end'])) $where[] = ['a.addtime', '<=', $param['end'] . ' 23:59:59'];
  1134. if (!empty($param['creater'])) $where[] = ['a.creater', 'like', '%' . $param['creater'] . '%'];
  1135. if (!empty($param['company_name'])) $where[] = ["a.creater_id", 'in', get_company_item_user_by_name($param['company_name'])];
  1136. $count = Db::name('purchease_change_supplier_log')
  1137. ->alias('a')
  1138. ->where($where)
  1139. ->count('a.id');
  1140. $list = Db::name('purchease_change_supplier_log')
  1141. ->alias('a')
  1142. ->where($where)
  1143. ->order('a.id', 'desc')
  1144. ->page($param['page'], $param['size'])
  1145. ->select()
  1146. ->toArray();
  1147. $all_createrid = array_column($list,'createrid');
  1148. $item = get_company_name_by_uid($all_createrid);
  1149. foreach ($list as &$value){
  1150. $val['company_name']=$item[$value['createrid']]??'';
  1151. }
  1152. return app_show(0, '获取成功', ['list' => $list, 'count' => $count]);
  1153. }
  1154. // public function create(){
  1155. // $customer = isset($this->post['customer_code'])&&$this->post['customer_code']!="" ?trim($this->post['customer_code']):"";
  1156. // if($customer==""){
  1157. // return error_show(1004,"参数customer_code不能为空");
  1158. // }
  1159. // $supplier = isset($this->post['supplier_code'])&&$this->post['supplier_code']!="" ?trim($this->post['supplier_code']):"";
  1160. // if($supplier==""){
  1161. // return error_show(1004,"参数supplier_code不能为空");
  1162. // }
  1163. // $good_code = isset($this->post['good_code']) && $this->post['good_code']!=""?trim($this->post['good_code']):"";
  1164. // if($good_code==""){
  1165. // return error_show(1004,"参数good_code不能为空");
  1166. // }
  1167. // $good_num = isset($this->post['good_num'])&& $this->post['good_num']!==""? intval($this->post['good_num']):"";
  1168. // if($good_num===""){
  1169. // return error_show(1004,"参数good_code不能为空");
  1170. // }
  1171. // $file_url = isset($this->post['file_url'])&& $this->post['file_url']!==""? trim($this->post['file_url']):"";
  1172. // if($file_url===""){
  1173. // return error_show(1004,"参数file_url不能为空");
  1174. // }
  1175. // $mark =isset($this->post['remark'])&&$this->post['remark']!=""?trim($this->post['remark']):"";
  1176. // if($mark==""){
  1177. // return error_show(1004,"参数remark不能为空");
  1178. // }
  1179. //
  1180. // $data=[
  1181. // ""
  1182. // ];
  1183. // }
  1184. }