Purch.php 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\model\ActionLog;
  4. use app\admin\model\ProcessOrder;
  5. use think\App;
  6. use think\Exception;
  7. use think\facade\Db;
  8. use think\facade\Validate;
  9. //采购单相关功能
  10. class Purch extends Base
  11. {
  12. public $noble=[];
  13. public function __construct(App $app)
  14. {
  15. parent::__construct($app);
  16. $this->noble=\think\facade\Config::get("noble");
  17. }
  18. public function list(){
  19. $page = isset($this->post['page']) && $this->post['page'] !=="" ? intval($this->post['page']):"1";
  20. $size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']):"10";
  21. $where = [['is_del', "=", 0], ['order_type', '<>', 5]];//不显示类型为5即订单导入生成的采购单
  22. $bkcode = isset($this->post['bk_code']) && $this->post['bk_code']!="" ? trim($this->post['bk_code']):"";
  23. if($bkcode!=""){
  24. $where[]=['bkcode',"like", "%{$bkcode}%"];
  25. }
  26. $status = isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
  27. if($status!==""){
  28. // $where['status'] = $status;
  29. $where[]=['status',"=", $status];
  30. }
  31. $cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo']!="" ? trim($this->post['cgdNo'])
  32. :"";
  33. if($cgdNo!=""){
  34. //$where['cgdNo'] = Db::Raw("like '%{$cgdNo}%'");
  35. $where[]=['cgdNo',"like", "%{$cgdNo}%"];
  36. }
  37. $apply_name = isset($this->post['apply_name']) && $this->post['apply_name']!="" ? trim($this->post['apply_name']):"";
  38. if($apply_name!=""){
  39. // $where['cgder'] =Db::Raw("like '%{$apply_name}%'");
  40. $where[]=['cgder',"like", "%{$apply_name}%"];
  41. }
  42. $wsm_code = isset($this->post['wsm_code']) && $this->post['wsm_code']!="" ? trim($this->post['wsm_code']):"";
  43. if($wsm_code!=""){
  44. // $where['wsm_code'] = $wsm_code;
  45. $where[]=['wsm_code',"=", $wsm_code];
  46. }
  47. $wsm_in_code = isset($this->post['wsm_in_code']) && $this->post['wsm_in_code']!="" ? trim($this->post['wsm_in_code']):"";
  48. if($wsm_in_code!=""){
  49. $incode = Db::name("purchease_in")->where(["wsm_in_code"=>Db::raw(" like %{$wsm_in_code}%"),"is_del"=>0])->column("cgdNo");
  50. if(empty($incode)){
  51. return error_show(1004,"未找到有关入库单信息");
  52. }
  53. $where[]=['cgdNo',"in", $incode];
  54. }
  55. $good_name = isset($this->post['good_name']) && $this->post['good_name']!="" ? trim($this->post['good_name']):"";
  56. if($good_name!=""){
  57. //$where['good_name'] = Db::raw(" like %{$good_name}%");
  58. $where[]=['good_name',"like", "%{$good_name}%"];
  59. }
  60. $good_code = isset($this->post['good_code']) && $this->post['good_code']!="" ? trim($this->post['good_code'])
  61. :"";
  62. if($good_code!=""){
  63. // $where['good_code'] = Db::raw(" like %{$good_code}%");
  64. $where[]=['spuCode',"like", "%{$good_code}%"];
  65. }
  66. $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo']!="" ? trim($this->post['supplierNo'])
  67. :"";
  68. if($supplierNo!=""){
  69. // $where['good_code'] = Db::raw(" like %{$good_code}%");
  70. $where[]=['supplierNo',"like", "%{$supplierNo}%"];
  71. }
  72. $wsm_supplierNo = isset($this->post['wsm_supplierNo']) && $this->post['wsm_supplierNo']!="" ? trim($this->post['wsm_supplierNo'])
  73. :"";
  74. if($wsm_supplierNo!=""){
  75. $supplier = Db::name("supplier")->where(["code"=>$wsm_supplierNo])->find();
  76. if(empty($supplier)){
  77. return error_show(1004,"未找到供应商信息");
  78. }
  79. $wsmcode = Db::name("warehouse_info")->where(["is_del"=>0,"supplierNo"=>$wsm_supplierNo])->column("wsm_code");
  80. $where[]=['wsm_code',"in", $wsmcode];
  81. }
  82. $start = isset($this->post['start']) && $this->post['start']!="" ?$this->post['start']:"";
  83. if($start!=""){
  84. // $where['addtime'] = Db::raw(" >= '{$start}'");
  85. $where[]=['addtime',">=", $start];
  86. }
  87. $end = isset($this->post['end']) && $this->post['end']!="" ?$this->post['end']:"";
  88. if($end!=""){
  89. $where[]=['addtime',"<=", $end];
  90. }
  91. $last_start = isset($this->post['last_start']) && $this->post['last_start']!="" ?$this->post['last_start']:"";
  92. if($last_start!=""){
  93. //$where['lasttime'] = Db::raw(" >= '{$last_start}'");
  94. $where[]=['lasttime',">=", $last_start];
  95. }
  96. $last_end = isset($this->post['last_end']) && $this->post['last_end']!="" ?$this->post['last_end']:"";
  97. if($last_end!=""){
  98. //$where['lasttime'] = Db::raw(" <= '{$last_end}'");
  99. $where[]=['lasttime',"<=", $last_end];
  100. }
  101. $role=$this->checkRole();
  102. if(!empty($role['write'])){
  103. $where[]=["cgder_id","in",$role['write']];
  104. }
  105. $count=Db::name("purchease_order")->where($where)->count();
  106. $total = ceil($count/$size);
  107. $page = $page >= $total ? $total : $page;
  108. $list = Db::name("purchease_order")->where($where)->page($page,$size)->order("addtime desc")->select();
  109. $data=[];
  110. foreach ($list as $value){
  111. $value['wsm_name']="";
  112. if($value['wsm_code']!=""){
  113. $wsmcode = Db::name("warehouse_info")->alias("a")->leftJoin("supplier b","a.supplierNo=b.code")
  114. ->where(["a.wsm_code"=>$value['wsm_code']])->field("a.name as wsm_name,b.name,b.code")->find();
  115. $value['wsm_name'] =isset($wsmcode['wsm_name']) ? $wsmcode['wsm_name']:"";
  116. $value['wsm_supplier'] =isset($wsmcode['name']) ? $wsmcode['name']:"";
  117. $value['wsm_supplierNo'] =isset($wsmcode['code']) ? $wsmcode['code']:"";
  118. }
  119. if($value['order_type']==3|| $value['order_type']==4){
  120. $goon = Db::name("good_zixun")->where(["spuCode"=>$value['spuCode'],"is_del"=>0])->find();
  121. $value["speclist"]=isset($goon['specinfo'])&&$goon['specinfo']!=""? json_decode($goon['specinfo'],true):"";
  122. }else {
  123. $goon =Db::name('good_basic')->where(['spuCode'=>$value['spuCode']])->find();
  124. $spec = Db::name("good_spec")->where(["spuCode"=>$goon['spuCode'],"is_del"=>0])->select()->toArray();
  125. $speclist=[];
  126. if(!empty($spec)){
  127. foreach ($spec as $val){
  128. $temp=[];
  129. $temp['id']=$val['id'];
  130. $temp['spuCode']=$val['spuCode'];
  131. $temp['spec_id']=$val['spec_id'];
  132. $temp['spec_value_id']=$val['spec_value_id'];
  133. $sp = Db::name("specs")->where(["id"=>$val['spec_id']])->find();
  134. $temp['spec_name']=isset($sp["spec_name"]) ? $sp["spec_name"]:"";
  135. $spv = Db::name("spec_value")->where(["id"=>$val['spec_value_id']])->find();
  136. $temp['spec_value']=isset($spv["spec_value"]) ? $spv["spec_value"]:"";
  137. $speclist[]=$temp;
  138. }
  139. }
  140. $value["speclist"]=empty($speclist)?[]:$speclist;
  141. }
  142. //采购单详情字段order_type 为1或者2时,取线上商品库 商品创建人 order_type 为3或者4时 取采购反馈的商品库 商品反馈人
  143. // $value['cgder_id'] = $goon['createrid'];
  144. // $value['cgder'] = $goon['creater'];
  145. $inorder= Db::name("purchease_in")->where(['cgdNo'=>$value['cgdNo'],"is_del"=>0])->select();
  146. $value['child']=empty($inorder)? [] : $inorder;
  147. $data[]=$value;
  148. }
  149. return app_show(0,"获取成功",["list"=>$data ,"count"=>$count]);
  150. }
  151. public function info(){
  152. $cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo']!="" ?trim($this->post['cgdNo']):"";
  153. if($cgdNo==""){
  154. return error_show(1004,"参数cgdNo 不能为空");
  155. }
  156. //采购单
  157. $data = Db::name("purchease_order")->where(["cgdNo"=>$cgdNo,"is_del"=>0])->find();
  158. if(empty($data)){
  159. return error_show(1004,"未找到数据");
  160. }
  161. //采购退货单
  162. $im = Db::name('purchease_back')->where(['cgdNo'=>$data['cgdNo'],'is_del'=>0])->select();
  163. $var=[];
  164. foreach ($im as $value){
  165. if($data['order_type']==3|| $data['order_type']==4){
  166. $goo = Db::name("good_zixun")->where(["spuCode"=>$value['spuCode'],"is_del"=>0])->find();
  167. }else {
  168. $goo =Db::name('good_basic')->where(['spuCode'=>$value['spuCode']])->find();
  169. }
  170. if($goo==false) {
  171. return error_show(1002, "未找到商品数据");
  172. }
  173. $cat= isset($goo['cat_id']) && $goo['cat_id'] !=0 ? made($goo['cat_id']):[];
  174. $value['cant']=$cat;
  175. $var[]=$value;
  176. }
  177. //采购工差单
  178. $dom = Db::name("purchease_diff")->where(['cgdNo'=>$data['cgdNo'],'is_del'=>0])->find();
  179. if($data['order_type']==3|| $data['order_type']==4){
  180. $goon = Db::name("good_zixun")->where(["spuCode"=>$data['spuCode'],"is_del"=>0])->find();
  181. }else {
  182. $goon =Db::name('good_basic')->where(['spuCode'=>$data['spuCode']])->find();
  183. }
  184. if(empty($goon)){
  185. return error_show(1002,"未找到商品数据");
  186. }else{
  187. $goon['exclusive']=isset($goon['is_exclusive'])?makeExcluse($goon['is_exclusive']):"";
  188. $unit =Db::name("unit")->where(["id"=>$goon['good_unit']])->find();
  189. $goon['unit'] = isset($unit['unit'])?$unit['unit']:'';
  190. $spec = Db::name("good_spec")->where(["spuCode"=>$goon['spuCode'],"is_del"=>0])->select()->toArray();
  191. $speclist=[];
  192. if(!empty($spec)){
  193. foreach ($spec as $value){
  194. $temp=[];
  195. $temp['id']=$value['id'];
  196. $temp['spuCode']=$value['spuCode'];
  197. $temp['spec_id']=$value['spec_id'];
  198. $temp['spec_value_id']=$value['spec_value_id'];
  199. $temp['is_del']=$value['is_del'];
  200. $sp = Db::name("specs")->where(["id"=>$value['spec_id']])->find();
  201. $temp['spec_name']=isset($sp["spec_name"]) ? $sp["spec_name"]:"";
  202. $spv = Db::name("spec_value")->where(["id"=>$value['spec_value_id']])->find();
  203. $temp['spec_value']=isset($spv["spec_value"]) ? $spv["spec_value"]:"";
  204. $speclist[]=$temp;
  205. }
  206. }
  207. $goon["speclist"]=empty($speclist)?[]:$speclist;
  208. $proof =Db::name("good_proof")->where(["spuCode"=>$goon['spuCode'],"is_del"=>0])->order("updatetime desc")->field("id,proof_type,proof_url")->find();
  209. $goon['proof'] = isset($proof)&&$proof!=false? $proof:[];
  210. $goon['origin_place_cn']="";
  211. $goon['delivery_place_cn']="";
  212. if(isset($goon['delivery_place'])&&$goon['delivery_place']!==""){
  213. $place = ["provice_code"=>"","city_code"=>"","area_code"=>""];
  214. list($place['provice_code'],$place['city_code'],$place['area_code'])=explode(",",$goon['delivery_place']);
  215. $goon['delivery_place_cn']=GetAddr(json_encode($place));
  216. }
  217. if(isset($goon['delivery_place'])&&$goon['origin_place']!==""){
  218. $place = ["provice_code"=>"","city_code"=>"","area_code"=>""];
  219. list($place['provice_code'],$place['city_code'],$place['area_code'])=explode(",",$goon['origin_place']);
  220. $goon['origin_place_cn']=GetAddr(json_encode($place));
  221. }
  222. if($goon['brand_id']!=0){
  223. $brand=Db::name("brand")->where(["id"=>$goon['brand_id']])->find();
  224. $goon["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  225. }else{
  226. $goon["brand_name"]="";
  227. $goon["brand_id"]="";
  228. }
  229. $supplier = Db::name("supplier")->where(["code"=>$goon['supplierNo']])->find();
  230. $goon['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  231. $goon['noble_name']=isset($goon['noble_metal'])&&$goon['noble_metal']!=0?$this->noble[$goon['noble_metal']] :"";
  232. if(isset($goon['companyNo'])&&$goon['companyNo']!=""){
  233. $company = Db::name("business")->where(["companyNo"=>$goon['companyNo']])->find();
  234. }
  235. $goon['company'] = isset($company['company'])?$company['company']:"";
  236. }
  237. $int= isset($goon['cat_id']) && $goon['cat_id'] !=0 ? made($goon['cat_id']):[];
  238. $data['wsm_name']="";
  239. if($data['wsm_code']!=""){
  240. $wsmcode = Db::name("warehouse_info")->alias("a")->leftJoin("supplier b","a.supplierNo=b.code")
  241. ->leftJoin("warehouse_addr c","a.wsm_code=c.wsm_code and c.is_del=0")
  242. ->where(["a.wsm_code"=>$data['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();
  243. $data['wsm_name'] =isset($wsmcode['wsm_name']) ? $wsmcode['wsm_name']:"";
  244. $data['wsm_supplier'] =isset($wsmcode['name']) ? $wsmcode['name']:"";
  245. $data['wsm_supplierNo'] =isset($wsmcode['code']) ? $wsmcode['code']:"";
  246. $data['wsm_contactor'] =isset($wsmcode['wsm_contactor']) ? $wsmcode['wsm_contactor']:"";
  247. $data['wsm_mobile'] =isset($wsmcode['wsm_mobile']) ? $wsmcode['wsm_mobile']:"";
  248. // $data['wsm_addr'] =isset($wsmcode['wsm_addr']) ? $wsmcode['wsm_addr']:"";
  249. $data['addr_code'] =isset($wsmcode['addr_code']) ? $wsmcode['addr_code']:"";
  250. $data['wsm_addr'] =isset($wsmcode['addr_code']) ? GetAddr($wsmcode['addr_code']):"";
  251. $data['wsm_addr'].=isset($wsmcode['wsm_addr']) ? $wsmcode['wsm_addr']:"";
  252. $inorder= Db::name("purchease_in")->where(['cgdNo'=>$data['cgdNo'],"is_del"=>0])->select();
  253. $data['child']=empty($inorder)? [] : $inorder;
  254. }
  255. $data['can'] = $int;
  256. $data['goodinfo'] = $goon;
  257. $data['purcheasediff'] = $dom;
  258. if(isset($data['companyNo'])&&$data['companyNo']!=""){
  259. $company = Db::name("business")->where(["companyNo"=>$data['companyNo']])->find();
  260. }
  261. $data['company'] = isset($company['company'])?$company['company']:"";
  262. //$data['info'] = $var;
  263. $data['purcheaseback'] = $var;
  264. return app_show(0,"获取成功",$data);
  265. }
  266. public function edit(){
  267. $cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo']!="" ?trim($this->post['cgdNo']):"";
  268. if($cgdNo==""){
  269. return error_show(1004,"参数cgdNo 不能为空");
  270. }
  271. $old = $data = Db::name("purchease_order")->where(["cgdNo"=>$cgdNo,"is_del"=>0])->find();
  272. if(empty($data)){
  273. return error_show(1004,"未找到数据");
  274. }
  275. $order = ["order_code"=>$cgdNo,"status"=> $data['status'] ,"action_remark"=>$this->post['remark'],"action_type"=>"edit"];
  276. $wsm_code = isset($this->post['wsm_code'])&&$this->post['wsm_code']!=""? trim($this->post['wsm_code']):"";
  277. if($wsm_code!=""){
  278. $ware = Db::name("warehouse_info")->where(["wsm_code"=>$wsm_code,"is_del"=>0])->find();
  279. if(empty($ware)){
  280. return error_show(1004,"未找到仓库信息");
  281. }
  282. // $good = Db::name("good_stock")->where(["wsm_code"=>$wsm_code,"good_type_code"=>$data['good_type_code'],"is_del"=>0])->find();
  283. // if(empty($good)){
  284. // return error_show(1004,"未找到仓库下商品信息");
  285. // }
  286. $data['wsm_code'] = $wsm_code;
  287. }
  288. $cgdid = isset($this->post['cgder_id'])&&$this->post['cgder_id']!=""?intval($this->post['cgder_id']):"";
  289. if($cgdid!=''){
  290. $cgduser = GetInfoById($this->post['token'],["id"=>$cgdid]);
  291. if((!empty($cgduser) && $cgduser['code']!=0) ||empty($cgduser) ){
  292. return error_show($cgduser['code'],$cgduser['message']);
  293. }
  294. $userinfo = $cgduser['data'];
  295. $data['cgder_id'] = $cgdid;
  296. $data['cgder'] = $userinfo['nickname'];
  297. }
  298. $good_num = isset($this->post['good_num'])&&$this->post['good_num']!=""?intval($this->post['good_num']):"";
  299. if($good_num!=""){
  300. $data['good_num'] = $good_num;
  301. }
  302. $good_price = isset($this->post['good_price'])&&$this->post['good_price']!=""?$this->post['good_price']:"";
  303. if($good_price!=""){
  304. $data['good_price'] = $good_price;
  305. }
  306. // $total_fee = isset($this->post['total_fee'])&&$this->post['total_fee']!=""?$this->post['total_fee']:"";
  307. // if($total_fee!=""){
  308. // $data['total_fee'] = $total_fee;
  309. // }
  310. $pakge_fee = isset($this->post['pakge_fee'])&&$this->post['pakge_fee']!=""?$this->post['pakge_fee']:"";
  311. if($pakge_fee!=""){
  312. $data['pakge_fee'] = $pakge_fee;
  313. }
  314. $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!=""?$this->post['cert_fee']:"";
  315. if($cert_fee!=""){
  316. $data['cert_fee'] = $cert_fee;
  317. }
  318. $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!=""?$this->post['open_fee']:"";
  319. if($open_fee!=""){
  320. $data['open_fee'] = $open_fee;
  321. }
  322. $delivery_fee = isset($this->post['delivery_fee'])&&$this->post['delivery_fee']!=""?$this->post['delivery_fee']:"";
  323. if($delivery_fee!=""){
  324. $data['delivery_fee'] = $delivery_fee;
  325. }
  326. $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!=""?$this->post['mark_fee']:"";
  327. if($mark_fee!=""){
  328. $data['mark_fee'] = $mark_fee;
  329. }
  330. $teach_fee = isset($this->post['teach_fee'])&&$this->post['teach_fee']!=""?$this->post['teach_fee']:"";
  331. if($teach_fee!=""){
  332. $data['teach_fee'] = $teach_fee;
  333. }
  334. $nake_fee = isset($this->post['nake_fee'])&&$this->post['nake_fee']!=""?$this->post['nake_fee']:"";
  335. if($nake_fee!=""){
  336. $data['nake_fee'] = $nake_fee;
  337. }
  338. $weight = isset($this->post['weight'])&&$this->post['weight']!=""?$this->post['weight']:"";
  339. if($weight!=""){
  340. $data['weight'] = $weight;
  341. }
  342. $diff_weight = isset($this->post['diff_weight'])&&$this->post['diff_weight']!=""?$this->post['diff_weight']:"";
  343. if($diff_weight!=""){
  344. $data['diff_weight'] = $diff_weight;
  345. }
  346. $diff_fee = isset($this->post['diff_fee'])&&$this->post['diff_fee']!=""?$this->post['diff_fee']:"";
  347. if($diff_fee!=""){
  348. $data['diff_fee'] = $diff_fee;
  349. }
  350. $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""?trim($this->post['supplierNo'])
  351. :"";
  352. if($supplierNo!=""){
  353. $supplier =Db::name("supplier")->where(['code'=>$supplierNo])->find();
  354. if(empty($supplier)){
  355. return error_show(1004,"未找到供应商信息");
  356. }
  357. $data['supplierNo'] = $supplierNo;
  358. $data['supplier_name'] = $supplier['name'];
  359. }
  360. $remark = isset($this->post['remark'])&&$this->post['remark']!=""?trim($this->post['remark']):"";
  361. if($remark!=""){
  362. $data['remark'] = $remark;
  363. }
  364. $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);
  365. $data['total_fee'] = round($data['good_price']*$data['good_num'],2);
  366. $data['updatetime'] =date("Y-m-d H:i:s");
  367. Db::startTrans();
  368. try{
  369. $upd=Db::name("purchease_order")->save($data);
  370. if($upd){
  371. // ActionLog::logAdd($this->post['token'],$order,'cgd',$data['status'],$this->post);
  372. //如果修改了供应商信息,需要记录
  373. if($supplierNo!="" && $supplierNo!=$old['supplierNo']){
  374. $change_log_data=[
  375. 'cgdNo'=>$cgdNo,
  376. 'cgder_id_old'=>$old['cgder_id'],
  377. 'cgder_id'=>$data['cgder_id'],
  378. 'cgder_old'=>$old['cgder'],
  379. 'cgder'=>$data['cgder'],
  380. 'supplierNo_old'=>$old['supplierNo'],
  381. 'supplierNo'=>$data['supplierNo'],
  382. 'supplier_name_old'=>$old['supplier_name'],
  383. 'supplier_name'=>$data['supplier_name'],
  384. 'addtime'=>date('Y-m-d H:i:s'),
  385. 'updatetime'=>date('Y-m-d H:i:s'),
  386. 'creater_id'=>$data['cgder_id'],
  387. 'creater'=>$data['cgder'],
  388. ];
  389. Db::name('purchease_change_supplier_log')->insert($change_log_data);
  390. }
  391. //修改状态,添加待办
  392. ActionLog::logAdd($this->post['token'], $order, "CGD", $data['status'], $this->post);
  393. ProcessOrder::AddProcess($this->post['token'], [
  394. "order_type" => 'CGD',
  395. "order_code" => $cgdNo,//销售单code
  396. "order_id" => $data['id'],
  397. "order_status" => $data['status']
  398. ]);
  399. Db::commit();
  400. return app_show(0,"更新成功");
  401. }else{
  402. Db::rollback();
  403. return error_show(1004,'更新失败');
  404. }
  405. }catch (Exception $exception){
  406. Db::rollback();
  407. return error_show(1004,'更新失败,'.$exception->getMessage());
  408. }
  409. }
  410. public function status()
  411. {
  412. $cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo'] != "" ? $this->post['cgdNo'] : [];
  413. if (empty($cgdNo)) {
  414. return error_show(1004, "参数cgdNo 不能为空");
  415. }
  416. $remark = isset($this->post['remark']) && $this->post['remark'] != "" ? trim($this->post['remark']) : "";
  417. $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
  418. if ($status === "") {
  419. return error_show(1004, "参数status 不能为空");
  420. }
  421. if ($status == 0) {
  422. $data = Db::name("purchease_order")
  423. ->field('id,cgdNo')
  424. ->whereIn('cgdNo', $cgdNo)
  425. ->where(["is_del" => 0])
  426. ->where('send_status', '>', 1)
  427. ->find();
  428. if (!empty($data)) {
  429. return error_show(1004, $data['cgdNo'] . "采购单发货中无法取消");
  430. }
  431. }
  432. // if($data['send_status']>1 && $status==0){
  433. // return error_show(1004,"采购单发货中无法取消");
  434. // }
  435. // $order = ["order_code"=>$cgdNo,"status"=> $data['status'] ,"action_remark"=>$remark,"action_type"=>"status"];
  436. // $data['status'] = $status;
  437. // $data['remark'] = $remark;
  438. // $data['updatetime'] =date("Y-m-d H:i:s");
  439. $upd = Db::name("purchease_order")
  440. ->whereIn('cgdNo', $cgdNo)
  441. ->save([
  442. 'status' => $status,
  443. 'remark' => $remark,
  444. 'updatetime' => date("Y-m-d H:i:s"),
  445. ]);
  446. if ($upd) {
  447. $process = ["order_code" => implode(',', $cgdNo), "order_id" => 0, "order_status" => $status, "order_type" => 'CGD'];
  448. ProcessOrder::AddProcess($this->post['token'], $process);
  449. $order = ["order_code" => implode(',', $cgdNo), "status" => '', "action_remark" => $remark, "action_type" => "status"];
  450. ActionLog::logAdd($this->post['token'], $order, 'CGD', $status, $this->post);
  451. return app_show(0, "更新成功");
  452. } else {
  453. return error_show(1004, '更新失败');
  454. }
  455. }
  456. public function diffcreat(){
  457. $token = isset($this->post['token']) && $this->post['token'] !=="" ?trim($this->post['token']):"";
  458. //$cgdNo=makeNo("CG");
  459. $cgdNo = $this->post['cgdNo'] && $this->post['cgdNo'] !=="" ? trim($this->post['cgdNo']) :"";
  460. if($cgdNo==""){
  461. return error_show(1002,"参数good_code不能为空");
  462. }
  463. $cg = Db::name('purchease_order')->where(['cgdNo'=>$cgdNo,'is_del'=>0])->find();
  464. if($cg==""){
  465. return error_show(1002,"未找到采购单数据");
  466. }
  467. if($cg['order_type']==3|| $cg['order_type']==4){
  468. $gd = Db::name("good_zixun")->where(["spuCode"=>$cg['spuCode']])->find();
  469. }else {
  470. $gd =Db::name('good_basic')->where(['spuCode'=>$cg['spuCode']])->find();
  471. }
  472. if($gd==""){
  473. return error_show(1002,"未找到商品数据");
  474. }
  475. $diff_weight = isset($this->post['diff_weight']) && $this->post['diff_weight'] !=="" ? floatval($this->post['diff_weight']) :"";
  476. if($diff_weight===""){
  477. return error_show(1002,"参数diff_weight不能为空");
  478. }
  479. $apply_id =GetUserInfo($token);
  480. if(empty($apply_id)||$apply_id['code']!=0){
  481. return error_show(1002,"申请人数据不存在");
  482. }
  483. $rid= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
  484. $rname= isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : "";
  485. $diff_price = round($diff_weight*$cg['gold_price']+$diff_weight*$cg['teach_fee'],2);
  486. $data=[
  487. "cgdNo"=>$cgdNo,
  488. "good_code"=>$cg['spuCode'],
  489. "good_name"=>$cg['good_name'],
  490. "sale_price"=>$cg['good_price'],
  491. "good_weight"=>$cg['weight']*$cg['good_num'],
  492. "good_num"=>$cg['good_num'],
  493. "apply_id"=>$rid,
  494. "apply_name"=>$rname,
  495. "diff_weight"=>$diff_weight,
  496. "diff_price"=>$diff_price,
  497. "gold_price"=>$cg['good_price'],
  498. "status"=>1,
  499. "is_del"=>0,
  500. "addtime"=>date("Y-m-d H:i:s"),
  501. "updatetime"=>date("Y-m-d H:i:s")
  502. ];
  503. Db::startTrans();
  504. try{
  505. $item = Db::name("purchease_diff")->insert($data,true);
  506. if($item>0){
  507. $sto = ["order_code"=>$cgdNo,"status"=>1,"action_remark"=>'',"action_type"=>"create"];
  508. ActionLog::logAdd($this->post['token'],$sto,"CGGCD",1,$data);
  509. $process=["order_code"=>$cgdNo,"order_id"=>$item,"order_status"=>1,"order_type"=>'CGGCD'];
  510. ProcessOrder::AddProcess($this->post['token'],$process);
  511. $orderCode = Db::name("order_num")->where([["cgdNo","=",$cg['cgdNo']],["status","=",1]])->find();
  512. if($orderCode!=false){
  513. $order = Db::name("sale")->where("orderCode", '=', $orderCode['orderCode'])->find();
  514. if($order==false){
  515. Db::rollback();
  516. return error_show(1002,"未找到确认单信息");
  517. }
  518. $data=[
  519. "cgd_diffid"=>$item,
  520. "orderCode"=>$orderCode['orderCode'],
  521. "good_code"=>$cg['spuCode'],
  522. "good_name"=>$cg['good_name'],
  523. "diff_weight"=>$diff_weight,
  524. "diff_price"=>round($diff_weight*$order['gold_price']+$diff_weight*$order['cost_price'],2),
  525. "gold_price"=>$order['sale_price'],
  526. "status"=>1,
  527. "addtime"=>date("Y-m-d H:i:s"),
  528. "updatetime"=>date("Y-m-d H:i:s")
  529. ];
  530. $cgd = Db::name('sale_diff')->insert($data,true);
  531. if($cgd==0){
  532. // $sto = ["order_code"=>$cg['bkcode'],"status"=>1,"action_remark"=>'',"action_type"=>"create"];
  533. // ActionLog::logAdd($this->post['token'],$sto,"ZXGCD",1,$sto);
  534. // $process=["order_code"=>$cg['bkcode'],"order_id"=>$cgd,"order_status"=>1,"order_type"=>'ZXGCD'];
  535. // ProcessOrder::AddProcess($this->post['token'],$process);
  536. // Db::commit();
  537. // return error_show(0,"新建成功");
  538. // }else{
  539. Db::rollback();
  540. return error_show(1002,"新建失败");
  541. }
  542. $sto = ["order_code"=>$orderCode['orderCode'],"status"=>1,"action_remark"=>'',"action_type"=>"create"];
  543. ActionLog::logAdd($this->post['token'],$sto,"XSGCD",1,$data);
  544. $process=["order_code"=>$orderCode['orderCode'],"order_id"=>$cgd,"order_status"=>1,"order_type"=>'XSGCD'];
  545. ProcessOrder::AddProcess($this->post['token'],$process);
  546. }
  547. Db::commit();
  548. return error_show(0,"新建成功");
  549. }else{
  550. Db::rollback();
  551. return error_show(1002,"新建失败");
  552. }
  553. }catch (\Exception $e){
  554. Db::rollback();
  555. return error_show(1002,$e->getMessage());
  556. }
  557. }
  558. public function difflist(){
  559. $page = isset($this->post['page']) && $this->post['page'] !==""? intval($this->post['page']):"1";
  560. $size = isset($this->post['size']) && $this->post['size'] !==""? intval($this->post['size']):"10";
  561. $where = [['a.is_del',"=",0]];
  562. $cgdNo = isset($this->post['cgdNo']) && $this->post['cgdNo']!="" ? trim($this->post['cgdNo']):"";
  563. if($cgdNo!=""){
  564. $where[]=['a.cgdNo',"like", "%$cgdNo%"];
  565. }
  566. $status = isset($this->post['status']) && $this->post['status'] !==""? intval($this->post['status']):"";
  567. if($status!==""){
  568. $where[]=['a.status',"=",$status];
  569. }
  570. $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
  571. if ($start !="") {
  572. $where[]= ["a.addtime",'>=',$start];
  573. }
  574. $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
  575. if($end !=""){
  576. $where[]= ["a.addtime",'<=',$end];
  577. }
  578. $apply_name = isset($this->post['apply_name']) && $this->post['apply_name'] !==""? intval($this->post['apply_name']):"";
  579. if($apply_name!==""){
  580. $where[]=['a.apply_name',"like","%$apply_name%"];
  581. }
  582. $count = Db::name('purchease_diff')->alias('a')->join("good b","b.spuCode=a.good_code","left")
  583. ->where($where)->count();
  584. $total = ceil($count/$size);
  585. $page = $page >= $total ? $total : $page;
  586. $list = Db::name('purchease_diff')->alias('a')->join("good b","b.spuCode=a.good_code","left")
  587. ->where($where)->page($page,$size)->order("a.addtime desc")->field("a.*,b.cat_id")->select();
  588. $data=[];
  589. foreach ($list as $value){
  590. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  591. $data[]=$value;
  592. }
  593. return app_show(0,"获取成功",['list'=>$data,'count'=>$count]);
  594. }
  595. public function diffinfo(){
  596. $id = isset($this->post['id']) && $this->post['id'] !=="" ? trim($this->post['id']) :"";
  597. if($id==""){
  598. return error_show(1002,"参数id 不能为空");
  599. }
  600. $idinf = Db::name('purchease_diff')->where(['id'=>$id,'is_del'=>0])->find();
  601. if($idinf==false){
  602. return error_show(1002,"未找到采购工差单数据");
  603. }
  604. $dn = Db::name('purchease_order')->where(['cgdNo'=>$idinf['cgdNo'],'is_del'=>0])->find();
  605. if($dn['order_type']==3|| $dn['order_type']==4){
  606. $goon = Db::name("good_zixun")->where(["spuCode"=>$dn['spuCode'],"is_del"=>0])->find();
  607. }else {
  608. $goon =Db::name('good_basic')->where(['spuCode'=>$dn['spuCode']])->find();
  609. }
  610. // $goon = Db::name('good')->where(['spuCode'=>$idinf['good_code']])->find();
  611. if(empty($goon)){
  612. return error_show(1002,"未找到商品数据");
  613. }
  614. $idinf['wsm_name'] ="";
  615. $idinf['wsm_supplier'] ="";
  616. $idinf['wsm_supplierNo'] ="";
  617. $idinf['wsm_contactor'] ="";
  618. $idinf['wsm_mobile'] ="";
  619. $idinf['addr_code'] ="";
  620. $idinf['wsm_addr'] ="";
  621. if($dn['wsm_code']!=""){
  622. $wsmcode = Db::name("warehouse_info")->alias("a")->leftJoin("supplier b","a.supplierNo=b.code")
  623. ->leftJoin("warehouse_addr c","a.wsm_code=c.wsm_code and c.is_del=0")
  624. ->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();
  625. $idinf['wsm_name'] =isset($wsmcode['wsm_name']) ? $wsmcode['wsm_name']:"";
  626. $idinf['wsm_supplier'] =isset($wsmcode['name']) ? $wsmcode['name']:"";
  627. $idinf['wsm_supplierNo'] =isset($wsmcode['code']) ? $wsmcode['code']:"";
  628. $idinf['wsm_contactor'] =isset($wsmcode['wsm_contactor']) ? $wsmcode['wsm_contactor']:"";
  629. $idinf['wsm_mobile'] =isset($wsmcode['wsm_mobile']) ? $wsmcode['wsm_mobile']:"";
  630. $idinf['addr_code'] =isset($wsmcode['addr_code']) ? $wsmcode['addr_code']:"";
  631. $idinf['addr_cn'] =isset($wsmcode['addr_code']) ? GetAddr($wsmcode['addr_code']):"";
  632. $idinf['wsm_addr']=isset($wsmcode['wsm_addr']) ? $wsmcode['wsm_addr']:"";
  633. }
  634. $idinf['info'] =$dn;
  635. $int= isset($goon['cat_id']) && $goon['cat_id'] !=0 ? made($goon['cat_id']):[];
  636. $idinf['can']=$int;
  637. $idinf['order_type']=$dn['order_type'];
  638. //取出销售的工差单信息
  639. $diff = Db::name('sale_diff')->field('id,customer_remark,is_act,remark')->where('cgd_diffid',$id)->find();
  640. $idinf['diff_customer_remark']=$diff['customer_remark'];
  641. $idinf['diff_is_act']=$diff['is_act'];
  642. $idinf['diff_remark']=$diff['remark'];
  643. return app_show(0,"获取成功",$idinf);
  644. }
  645. public function diffstatu(){
  646. $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) :"";
  647. if($id==""){
  648. return error_show(1002,"参数id不能为空");
  649. }
  650. $dio = Db::name('purchease_diff')->where(['id'=>$id,'is_del'=>0])->find();
  651. if(empty($dio)){
  652. return error_show(1002,"工差订单未找到");
  653. }
  654. $cgd = Db::name("purchease_order")->where(['cgdNo'=>$dio['cgdNo']])->find();
  655. if(empty($cgd)){
  656. return error_show(1002,"采购单未找到");
  657. }
  658. $salediff=Db::name("sale_diff")->where(["cgd_diffid"=>$dio['id']])->find();
  659. if($salediff==false){
  660. return error_show(1002,"销售工差单未找到");
  661. }
  662. $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"";
  663. if($status===""){
  664. return error_show(1002,"参数status不能为空");
  665. }
  666. Db::startTrans();
  667. try{
  668. $temp = $dio['status'];
  669. $dio['status']=$status;
  670. $dio['updatetime']=date("Y-m-d H:i:s");
  671. $item = Db::name("purchease_diff")->save($dio);
  672. if ($item){
  673. if($status==2){
  674. $cgd['diff_fee'] =$dio['diff_price'];
  675. $cgd['diff_weight'] =$dio['diff_weight'];
  676. $cgd['updatetime'] =date("Y-m-d H:i:s");
  677. $cgp=Db::name("purchease_order")->save($cgd);
  678. if($cgp==false){
  679. Db::rollback();
  680. return error_show(1002,"采购单更新失败");
  681. }
  682. if($salediff['is_act']==1){
  683. $saled=[
  684. "diff_fee"=>$salediff['diff_price'],
  685. "diff_weight"=>$salediff['diff_weight'],
  686. "updatetime"=>date("Y-m-d H:i:s")
  687. ];
  688. $up =Db::name("sale")->where(["orderCode"=>$salediff['orderCode']])->save($saled);
  689. if($up==false){
  690. Db::rollback();
  691. return error_show(1002,"销售单更新失败");
  692. }
  693. }
  694. }
  695. $sto = ["order_code"=>$dio['cgdNo'],"status"=>1,"action_remark"=>'',"action_type"=>"create"];
  696. ActionLog::logAdd($this->post['token'],$sto,"CGGCD",$status,$this->post);
  697. $process=["order_code"=>$dio['cgdNo'],"order_id"=>$dio['id'],"order_status"=>$status,"order_type"=>'CGGCD'];
  698. ProcessOrder::AddProcess($this->post['token'],$process);
  699. Db::commit();
  700. return error_show(0,"更新成功");
  701. }else{
  702. Db::rollback();
  703. return error_show(1002,"更新失败");
  704. }
  705. }catch (\Exception $e){
  706. Db::rollback();
  707. return error_show(1002,$e->getMessage()."|".$e->getLine());
  708. }
  709. }
  710. //修改采购单的实时金价
  711. public function editGoldPrice()
  712. {
  713. $param = $this->request->only(['cgdNo', 'gold_price'], 'post', 'trim');
  714. $val = Validate::rule(['cgdNo|采购单号' => 'require', 'gold_price|实时金价' => 'require|float']);
  715. if (!$val->check($param)) return error_show(1004, $val->getError());
  716. //采购单
  717. $data = Db::name("purchease_order")
  718. ->field('id,demo_fee,good_num,weight,open_fee,teach_fee,pakge_fee,mark_fee,cert_fee,nake_fee,delivery_fee,status')
  719. ->where(["cgdNo" => $param['cgdNo'], "is_del" => 0])
  720. ->find();
  721. if (empty($data)) return error_show(1004, "未找到该采购单数据");
  722. if ($data['status'] != 0) return error_show(1005, '该状态下不允许修改实时金价');
  723. $sale_price = round($data['demo_fee'] / $data['good_num'] + $data['open_fee'] / $data['good_num'] +
  724. $data['weight'] * $param["gold_price"] + $data['teach_fee'] * $data['weight'] +
  725. $data['pakge_fee'] + $data['mark_fee'] + $data['cert_fee'] +$data['nake_fee'] + $data['delivery_fee'],2);
  726. $total_price = round($data['good_num']*$sale_price,2);
  727. $rs = Db::name("purchease_order")
  728. ->where('id', $data['id'])
  729. ->update(['updatetime' => date('Y-m-d H:i:s'), 'gold_price' => $param['gold_price'],"good_price"=>$sale_price,"total_fee"=>$total_price]);
  730. return $rs ? app_show(0, '修改采购单实时金价成功') : error_show(1005, '修改采购单实时金价失败');
  731. }
  732. //采购单导出
  733. public function exportCgdList()
  734. {
  735. $cgdNos = $this->request->post('cgdNos', [], 'trim');
  736. if (empty($cgdNos)) return error_show(1004, '要导出的采购单编号不能为空');
  737. $i = 1;
  738. $send_type = [1 => '直接发货', 2 => '延时发货'];
  739. $status = [0 => '待与供应商确认', 1 => '待入库', 2 => '部分入库', 3 => '入库完成', 4 => '已取消订单'];
  740. $list = Db::name("purchease_order")
  741. ->alias('po')
  742. ->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 采购货款,b.company as 购买方公司,s.arrive_time as 到货时间,po.order_type')
  743. ->whereIn('po.cgdNo', $cgdNos)
  744. ->leftJoin('order_num on', 'on.cgdNo=po.cgdNo')
  745. ->leftJoin('sale s', 's.orderCode=on.orderCode')
  746. ->leftJoin('business b', 'b.companyNo=s.supplierNo')
  747. ->order("po.addtime desc")
  748. ->withAttr('序号', function () use (&$i) {
  749. return $i++;
  750. })->withAttr('采购单状态', function ($val) use ($status) {
  751. return isset($status[$val]) ? $status[$val] : '';
  752. })->withAttr('发货方式', function ($val) use ($send_type) {
  753. return isset($send_type[$val]) ? $send_type[$val] : '';
  754. })
  755. ->select()
  756. ->toArray();
  757. foreach ($list as &$value) {
  758. if ($value['order_type'] == 3 || $value['order_type'] == 4) {
  759. $temp = Db::name("good_zixun")
  760. ->where(["spuCode" => $value['产品编号'], "is_del" => 0])
  761. ->field('id,specinfo,good_unit')
  762. ->find();
  763. $good_unit = isset($temp['good_unit']) ? $temp['good_unit'] : 0;
  764. $specinfo = isset($temp['specinfo']) ? json_decode($temp['specinfo'], true) : [];
  765. $speclist = [];
  766. foreach ($specinfo as $val) {
  767. $speclist[] = $val['spec_name'] . ':' . $val['spec_value_name'];
  768. }
  769. } else {
  770. $good_unit = Db::name('good_basic')
  771. ->where(['spuCode' => $value['产品编号']])
  772. ->value('good_unit', 0);
  773. $spec = Db::name("good_spec")
  774. ->field('id,spec_id,spec_value_id')
  775. ->where(["spuCode" => $value['产品编号'], "is_del" => 0])
  776. ->select()
  777. ->toArray();
  778. $speclist = [];
  779. if (!empty($spec)) {
  780. foreach ($spec as $val) {
  781. $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', '');
  782. }
  783. }
  784. }
  785. $value['规格'] = empty($speclist) ? '' : implode(',', $speclist);;
  786. $value['单位'] = $good_unit ? Db::name('unit')->where(['id' => $good_unit, 'is_del' => 0])->value('unit', '') : '';
  787. unset($value['order_type']);
  788. }
  789. $headerArr = array_keys($list[0]);
  790. excelSave('采购单导出' . date('YmdHis'), $headerArr, $list);
  791. }
  792. //获取采购单修改供应商的记录列表
  793. public function getChangeSupplierList(){
  794. $param = $this->request->only(['cgdNo'=>'','start'=>'','end'=>'','page'=>1,'size'=>15],'post','trim');
  795. $where=[['is_del','=',0]];
  796. if(!empty($param['cgdNo'])) $where[]=['cgdNo','like','%'.$param['cgdNo'].'%'];
  797. if(!empty($param['start'])) $where[]=['addtime','>=',$param['start']];
  798. if(!empty($param['end'])) $where[]=['addtime','<=',$param['end'].' 23:59:59'];
  799. $total = Db::name('purchease_change_supplier_log')
  800. ->where($where)
  801. ->count('id');
  802. $list =Db::name('purchease_change_supplier_log')
  803. ->withoutField('status,remark')
  804. ->where($where)
  805. ->order('id','desc')
  806. ->page($param['page'],$param['size'])
  807. ->select()
  808. ->toArray();
  809. return app_show(0,'获取成功',['list'=>$list,'count'=>$total]);
  810. }
  811. // public function create(){
  812. // $customer = isset($this->post['customer_code'])&&$this->post['customer_code']!="" ?trim($this->post['customer_code']):"";
  813. // if($customer==""){
  814. // return error_show(1004,"参数customer_code不能为空");
  815. // }
  816. // $supplier = isset($this->post['supplier_code'])&&$this->post['supplier_code']!="" ?trim($this->post['supplier_code']):"";
  817. // if($supplier==""){
  818. // return error_show(1004,"参数supplier_code不能为空");
  819. // }
  820. // $good_code = isset($this->post['good_code']) && $this->post['good_code']!=""?trim($this->post['good_code']):"";
  821. // if($good_code==""){
  822. // return error_show(1004,"参数good_code不能为空");
  823. // }
  824. // $good_num = isset($this->post['good_num'])&& $this->post['good_num']!==""? intval($this->post['good_num']):"";
  825. // if($good_num===""){
  826. // return error_show(1004,"参数good_code不能为空");
  827. // }
  828. // $file_url = isset($this->post['file_url'])&& $this->post['file_url']!==""? trim($this->post['file_url']):"";
  829. // if($file_url===""){
  830. // return error_show(1004,"参数file_url不能为空");
  831. // }
  832. // $mark =isset($this->post['remark'])&&$this->post['remark']!=""?trim($this->post['remark']):"";
  833. // if($mark==""){
  834. // return error_show(1004,"参数remark不能为空");
  835. // }
  836. //
  837. // $data=[
  838. // ""
  839. // ];
  840. // }
  841. }