Version.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\model\ActionLog;
  4. use app\admin\model\ProcessOrder;
  5. use app\BaseController;
  6. use think\App;
  7. use think\facade\Db;
  8. //版本
  9. class Version extends BaseController
  10. {
  11. public function __construct(App $app)
  12. {
  13. parent::__construct($app);
  14. $this->post = $this->request->post();
  15. }
  16. public function list(){
  17. $page = isset($this->post['page'])&&$this->post['page']!="" ? intval($this->post['page']) : 1;
  18. $size = isset($this->post['size'])&&$this->post['size']!="" ? intval($this->post['size']) :10;
  19. $count= Db::name("version")->count();
  20. $total = ceil($count/$size);
  21. $page = $page>=$total? $total:$page;
  22. $list = Db::name("version")->page($page,$size)->order("addtime desc")->select();
  23. return app_show(0,"获取成功",["list"=>$list,"count"=>$count]);
  24. }
  25. public function create(){
  26. $title = isset($this->post['title'])&&$this->post['title']!="" ? $this->post['title']:"";
  27. if($title==""){
  28. return error_show(1004,"参数title 不能为空");
  29. }
  30. $content = isset($this->post['content'])&&$this->post['content']!="" ? $this->post['content']:"";
  31. if($content==""){
  32. return error_show(1004,"参数content 不能为空");
  33. }
  34. $version = isset($this->post['version'])&&$this->post['version']!="" ? $this->post['version']:"";
  35. if($version==""){
  36. return error_show(1004,"参数version 不能为空");
  37. }
  38. $data=[
  39. "title"=>$title,
  40. "content"=>$content,
  41. "version"=>$version,
  42. "addtime"=>date("Y-m-d H:i:s")
  43. ];
  44. $inert= Db::name("version")->insert($data);
  45. if($inert){
  46. return app_show(0,"版本信息新建成功");
  47. }else{
  48. return app_show(0,"版本信息新建失败");
  49. }
  50. }
  51. public function info(){
  52. $projectNo = isset($this->post['projectNo'])&&$this->post['projectNo']!==""?trim($this->post['projectNo']):"";
  53. if($projectNo==""){
  54. return error_show(1004,"参数projectNo不能为空");
  55. }
  56. $type = isset($this->post['type'])&&$this->post['type']!=="" ? intval($this->post['type']) :0;
  57. $info =Db::name("project")->where(["projectNo"=>$projectNo,"is_del"=>0])->find();
  58. if($info==false){
  59. return error_show(1004,"未找到项目信息");
  60. }
  61. $plat = Db::name("platform")->where(['id'=>$info['platform_id']])->find();
  62. $info['platform_name']=isset($plat['platform_name'])?$plat['platform_name']:"";
  63. $info['platform_code']=isset($plat['platform_code'])?$plat['platform_code']:"";
  64. $khinfo = Db::name("customer_info")->where(["companyNo"=>$info['khNo']])->find();
  65. $info['khName'] = isset($khinfo['companyName'])?$khinfo['companyName']:"";
  66. $company = Db::name("business")->where(["companyNo"=>$info['companyNo']])->find();
  67. $info['company'] = isset($company['company'])?$company['company']:"";
  68. $ladder = Db::name("project_info")->where(['projectNo'=>$projectNo,"is_del"=>0])->select()->toArray();
  69. $info['ladder']=[];
  70. if(!empty($ladder)){
  71. foreach ($ladder as $value){
  72. $value["cat_info"]=isset($value['cat_id']) &&$value['cat_id']!=""? made($value['cat_id'],[]):[];
  73. $condition = $type==0?['pgNo'=>$value['pgNo'],"is_del"=>0] : ['pgNo'=>$value['pgNo'],"is_del"=>0,"status"=>1];
  74. $feedback = Db::name("project_feedback")->where($condition)->select()->toArray();
  75. array_walk($feedback,function (&$v){
  76. $v["cat_info"]=isset($v['cat_id'])&&$v['cat_id']!=""? made($v['cat_id'],[]):[];
  77. });
  78. $value['feedback']=$feedback;
  79. $info['ladder'][]=$value;
  80. }
  81. }
  82. return app_show(0,"获取成功",$info);
  83. }
  84. public function feedlist(){
  85. $page =isset($this->post['page'])&&$this->post['page']!=="" ? intval($this->post['page']):1;
  86. $size =isset($this->post['size'])&&$this->post['size']!==""? intval($this->post['size']):10;
  87. $where=[["is_del","=",0]];
  88. $pgNo =isset($this->post['pgNo'])&&$this->post['pgNo']!==""?trim($this->post['pgNo']):"";
  89. if($pgNo!==""){
  90. $where[]=["pgNo","=",$pgNo];
  91. }
  92. $projectNo =isset($this->post['projectNo'])&&$this->post['projectNo']!==""?trim($this->post['projectNo']):"";
  93. if($projectNo!==""){
  94. $where[]=["projectNo","=",$projectNo];
  95. }
  96. $source =isset($this->post['source'])&&$this->post['source']!==""?intval($this->post['source']):"";
  97. if($source!==""){
  98. $where[]=["data_source","=",$source];
  99. }
  100. $cat_id =isset($this->post['cat_id'])&&$this->post['cat_id']!==""?intval($this->post['cat_id']):"";
  101. if($cat_id!==""){
  102. $where[]=["cat_id","=",$cat_id];
  103. }
  104. $status =isset($this->post['status'])&&$this->post['status']!==""?intval($this->post['status']):"";
  105. if($status!==""){
  106. $where[]=["status","=",$status];
  107. }
  108. $count = Db::name('project_feedback')->where($where)->count();
  109. $total = ceil($count / $size);
  110. $page = $page >= $total ? $total : $page;
  111. $list = Db::name('project_feedback')->where($where)->page($page,$size)->order("addtime desc")->select();
  112. $data=[];
  113. foreach ($list as $value){
  114. $value['can']=isset($value['cat_id'])&&$value['cat_id']!=""?made($value['cat_id']):"";
  115. if($value['data_source']==1){
  116. $good=Db::name("good_platform")->alias("a")->leftJoin("good b","a.spuCode=b.spuCode")->where
  117. (["a.skuCode"=>$value['skuCode'],"a.is_del"=>0])->find();
  118. $nake = Db::name("good_nake")->where([["spuCode","=",$value['spuCode']],["min_num","<=",
  119. $value["num"]],["is_del","=",0]])->order("min_num desc")->find();
  120. $good['unit_id'] = isset($good['good_unit'])?$good['good_unit']:"";
  121. $good['cost_desc'] = isset($good['craft_desc'])?$good['craft_desc']:"";
  122. $good['pakge_fee'] = isset($nake['package_fee'])?$nake['package_fee']:"0";
  123. $good['mark_fee'] = isset($nake['mark_fee'])?$nake['mark_fee']:"0";
  124. $good['other_fee'] = isset($nake['other_fee'])?$nake['other_fee']:"0";
  125. $good['cert_fee'] = isset($nake['cert_fee'])?$nake['cert_fee']:"0";
  126. $good['delivery_fee'] = isset($nake['delivery_fee'])?$nake['delivery_fee']:"0";
  127. $good['nake_fee'] = isset($nake['nake_fee'])?$nake['nake_fee']:"0";
  128. $good['metal_id'] = isset($good['noble_metal'])?$good['noble_metal']:"0";
  129. $spec = Db::name("good_spec")->where(["spuCode"=>$good['spuCode'],"is_del"=>0])->select()->toArray();
  130. $good['specinfo']=[];
  131. if(!empty($spec)){
  132. foreach ($spec as $vae){
  133. $specs=Db::name("specs")->where(["id"=>$vae['spec_id']])->find();
  134. $spec_value = Db::name("spec_value")->where(["id"=>$vae["spec_value_id"]])->find();
  135. $temp = ["specid"=>$vae['spec_id'],"spec_name"=>$specs['spec_name'],"spec_value_id"=>$vae['spec_value_id'],"spec_value_name"=>$spec_value["spec_value"]];
  136. $good['specinfo'][]=$temp;
  137. }
  138. }
  139. $nake =Db::name("good_nake")->where(["spuCode"=>$good['spuCode'],"is_del"=>0])->where([["min_num","<=",$value['num']]])
  140. ->order("min_num desc")->find();
  141. $good['origin_price']=$nake['nake_total'];
  142. $good['work_day']=$good['lead_time'];
  143. $good_img = $good['good_thumb_img'];
  144. }else{
  145. $good=Db::name("consult_bids")->where(["spuCode"=>$value['spuCode'],"is_del"=>0])->find();
  146. $good['specinfo'] = isset($good['specinfo'])&&$good['specinfo']!=""?json_decode($good['specinfo'],
  147. true):"";
  148. $catinfo = Db::name("cat")->where(["id"=>$good['cat_id']])->find();
  149. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:100;
  150. $good_img = $good['good_img'];
  151. }
  152. $nobel =\think\facade\Config::get("noble");
  153. $value['good_name'] = isset($good['good_name'])?$good['good_name']:"";
  154. // $value['good_img'] = isset($good['good_img'])?$good['good_img']:"";
  155. $value['brand_id'] = isset($good['brand_id'])?$good['brand_id']:"";
  156. $brand = Db::name("brand")->where(['id'=>$value["brand_id"]])->find();
  157. $value['brand_name'] =isset($brand['brand_name']) ? $brand['brand_name']:"";
  158. $value['specinfo'] = isset($good['specinfo'])&&$good['specinfo']!=""?$good['specinfo']:[];
  159. $value['unit_id'] = isset($good['unit_id'])?$good['unit_id']:"";
  160. $unit = Db::name("unit")->where(['id'=>$value["unit_id"]])->find();
  161. $value["unit_name"]=isset($unit['unit'])?$unit['unit']:"";
  162. $value['cost_desc'] = isset($good['cost_desc'])?$good['cost_desc']:"";
  163. $value['work_day'] = isset($good['work_day'])?$good['work_day']:"";
  164. $value['delivery_day'] = isset($good['delivery_day'])?$good['delivery_day']:"";
  165. $value['expire_day'] = isset($good['expire_day'])?$good['expire_day']:"0";
  166. $value['good_img'] = $good_img;
  167. $value['expire_day'] = isset($good['expire_day'])?$good['expire_day']:"";
  168. $value['origin_place'] = isset($good['origin_place'])?$good['origin_place']:"";
  169. $value['supplierNo'] = isset($good['supplierNo'])?$good['supplierNo']:"";
  170. $value['pay_way'] = isset($good['pay_way'])?$good['pay_way']:"";
  171. $value['tax'] = isset($good['tax'])?$good['tax']:"";
  172. $value['send_way'] = isset($good['send_way'])?$good['send_way']:"";
  173. $value['metal_id'] = isset($good['metal_id'])?$good['metal_id']:"";
  174. $value['metal_name'] = isset($nobel[$good['metal_id']])?$nobel[$good['metal_id']]:"";
  175. $value['is_gold_price'] = isset($good['is_gold_price'])?$good['is_gold_price']:"0";
  176. $value['config'] = isset($good['config'])?$good['config']:"";
  177. $value['other_config'] = isset($good['other_config'])?$good['other_config']:"";
  178. $value['weight'] = isset($good['weight'])?$good['weight']:"";
  179. $value['is_diff'] = isset($good['is_diff'])?$good['is_diff']:"0";
  180. $value['demo_fee'] = isset($good['demo_fee'])?$good['demo_fee']:"0";
  181. $value['deivery_fee'] = isset($good['deivery_fee'])?$good['deivery_fee']:"0";
  182. $value['open_fee'] = isset($good['open_fee'])?$good['open_fee']:"0";
  183. $value['pakge_fee'] = isset($good['pakge_fee'])?$good['pakge_fee']:"0";
  184. $value['nake_fee'] = isset($good['nake_fee'])?$good['nake_fee']:"0";
  185. $value['mark_fee'] = isset($good['mark_fee'])?$good['mark_fee']:"0";
  186. $value['cert_fee'] = isset($good['cert_fee'])?$good['cert_fee']:"0";
  187. $value['cost_fee'] = isset($good['cost_fee'])?$good['cost_fee']:"0";
  188. $value['rate'] = $value['sale_price'] == 0 ? 0 : round(($value['sale_price'] - $value['origin_price']) / $value['sale_price'] * 100, 2);
  189. $value['supply_area'] = isset($good['supply_area'])?$good['supply_area']:"";
  190. $data[]=$value;
  191. }
  192. return app_show(0,"获取成功",['list'=>$data,'count'=>$count]);
  193. }
  194. public function project_plan(){
  195. $projectNo = isset($this->post['projectNo'])&&$this->post['projectNo']!==""?trim($this->post['projectNo']):"";
  196. if($projectNo==""){
  197. return error_show(1004,"参数projectNo不能为空");
  198. }
  199. $type = isset($this->post['type'])&&$this->post['type']!=="" ? intval($this->post['type']) :0;
  200. $info =Db::name("project")->where(["projectNo"=>$projectNo,"is_del"=>0])->find();
  201. if($info==false){
  202. return error_show(1004,"未找到项目信息");
  203. }
  204. $plat = Db::name("platform")->where(['id'=>$info['platform_id']])->find();
  205. $info['platform_name']=isset($plat['platform_name'])?$plat['platform_name']:"";
  206. $info['platform_code']=isset($plat['platform_code'])?$plat['platform_code']:"";
  207. $khinfo = Db::name("customer_info")->where(["companyNo"=>$info['khNo']])->find();
  208. $info['khName'] = isset($khinfo['companyName'])?$khinfo['companyName']:"";
  209. if($type==1){
  210. $where = ['projectNo'=>$projectNo,"is_del"=>0,"status"=>1];
  211. }else{
  212. $where = ['projectNo'=>$projectNo,"is_del"=>0];
  213. }
  214. $ladder = Db::name("project_plan")->where($where)->order("addtime desc")->select()->toArray();
  215. $info=[];
  216. if(!empty($ladder)){
  217. foreach ($ladder as $value){
  218. $value['feedback']=[];
  219. $feedback =Db::name("project_plan_rela")->where(["planNo"=>$value['planNo'],"is_del"=>0])->column("feedback_id,sale_price,sale_num");
  220. if(!empty($feedback)){
  221. $feedid = array_column($feedback,"feedback_id");
  222. $feedlist = Db::name("project_feedback")->where(["id"=>$feedid,"is_del"=>0])->select();
  223. if(!empty($feedlist)){
  224. foreach ($feedlist as $val){
  225. $key =array_search($val['id'],$feedid);
  226. $price = $feedback[$key]['sale_price'];
  227. $val["cat_info"]=isset($val['cat_id'])&&$val['cat_id']!=""? made($val['cat_id'],[]):[];
  228. $val["sale_price"]=$price;
  229. $val["origin_num"]=$val['num'];
  230. $val["num"]=$feedback[$key]['sale_num'];
  231. if($val['data_source']!=1){
  232. $good=Db::name("consult_bids")->where(["spuCode"=>$val['spuCode'],"is_del"=>0])->find();
  233. $good['specinfo']=isset($good['specinfo'])&&$good['specinfo']!=""?json_decode($good['specinfo'],true):[];
  234. }else{
  235. $good=Db::name("good")->where(["spuCode"=>$val['spuCode'],"is_del"=>0])->find();
  236. $spec = Db::name("good_spec")->where(["spuCode"=>$val['spuCode'],"is_del"=>0])->select()->toArray();
  237. $good['specinfo']=[];
  238. if(!empty($spec)){
  239. foreach ($spec as $vae){
  240. $specs=Db::name("specs")->where(["id"=>$vae['spec_id']])->find();
  241. $spec_value = Db::name("spec_value")->where(["id"=>$vae["spec_value_id"]])->find();
  242. $temp = ["specid"=>$vae['spec_id'],"spec_name"=>$specs['spec_name'],"spec_value_id"=>$vae['spec_value_id'],"spec_value_name"=>$spec_value["spec_value"]];
  243. $good['specinfo'][]=$temp;
  244. }
  245. }
  246. }
  247. if(isset($good['brand_id'])){
  248. $brand =Db::name("brand")->where(["id"=>$good['brand_id']])->find();
  249. }
  250. $val['good_img']=isset($good['good_img'])&&$good['good_img']!=""?trim($good['good_img']):"";
  251. $val['brand_id']=isset($good['brand_id'])&&$good['brand_id']!=""?$good['brand_id']:"";
  252. $val['brand_name']=isset($brand['brand_name'])&&$brand['brand_name']!=""?$brand['brand_name']:"";
  253. $val['specinfo']=isset($good['specinfo'])&&$good['specinfo']!=""?$good['specinfo']:[];
  254. $value['feedback'][]=$val;
  255. }
  256. }
  257. }
  258. $info[]=$value;
  259. }
  260. }
  261. return app_show(0,"获取成功",$info);
  262. }
  263. public function feedCheck(){
  264. $feedid = isset($this->post['feedid'])&&!empty($this->post['feedid']) ? $this->post['feedid'] :[];
  265. if(empty($feedid)){
  266. return error_show(1004,"参数feedid不能为空");
  267. }
  268. $feedid=array_unique($feedid);
  269. $selec = Db::name("project_feedback")->where(["id"=>$feedid,'is_del'=>0,"status"=>0])->select()->toArray();
  270. if(empty($selec)){
  271. return error_show(1004,"反馈数据信息未找到");
  272. }
  273. $pgnos =array_column($selec,"pgNo");
  274. $infolist = Db::name("project_info")->where(['pgNo'=>$pgnos])->select()->toArray();
  275. if(empty($infolist)){
  276. return error_show(1004,"项目商品数据未找到");
  277. }
  278. Db::startTrans();
  279. try{
  280. $up = Db::name("project_feedback")->where(["id"=>$feedid,'is_del'=>0,"status"=>0])->save(["status"=>1,"updatetime"=>date("Y-m-d H:i:s")]);
  281. if($up){
  282. foreach ($infolist as $value){
  283. $old_value_status = $value['status'];
  284. $value['status']=3;
  285. $value['updatetime']=date("Y-m-d H:i:s");
  286. $up = Db::name("project_info")->save($value);
  287. if($up){
  288. ActionLog::logAdd(['id'=>0,"nickname"=>'客户'], [
  289. "order_code" => $value['pgNo'],//项目编码
  290. "status" =>$old_value_status,//这里的status是之前的值
  291. "action_remark" => '',//备注
  292. "action_type" => "edit"//新建create,编辑edit更改状态status
  293. ], "PRI", 3, ["status" =>3, "updatetime" => date("Y-m-d H:i:s")]);
  294. $count = Db::name("project_info")->where(["projectNo"=>$value['projectNo'],"status"=>2])
  295. ->count();
  296. if($count==0){
  297. $pr=Db::name("project")->where(["projectNo" => $value['projectNo']])->find();
  298. if($pr==false){
  299. Db::rollback();
  300. return error_show(1004, "未找到项目信息");
  301. }
  302. $proc =Db::name("project")->where(["projectNo"=>$value['projectNo']])->save
  303. (["status"=>3,"updatetime"=>date("Y-m-d H:i:s")]);
  304. if(!$proc){
  305. Db::rollback();
  306. return error_show(1004,"反馈数据选择失败");
  307. }
  308. ActionLog::logAdd(['id'=>0,"nickname"=>'客户'], [
  309. "order_code" => $value['projectNo'],//项目编码
  310. "status" =>$pr['status'],//这里的status是之前的值
  311. "action_remark" => '',//备注
  312. "action_type" => "edit"//新建create,编辑edit更改状态status
  313. ], "PRO", 3, ["status" => 3, "updatetime" => date("Y-m-d H:i:s")]);
  314. $process = ["order_code" => $value['projectNo'], "order_id" => $pr['id'], "order_status" =>3, "order_type" => 'PRO',"before_status"=> $pr['status'],'holder_id'=>$pr['createrid']];
  315. ProcessOrder::AddProcess(['id'=>0,"nickname"=>'客户'], $process);
  316. }
  317. }else{
  318. Db::rollback();
  319. return error_show(1004,"反馈数据选择失败");
  320. }
  321. $consult =Db::name('consult_order')->where(["projectNo"=>$value['projectNo']])->find();
  322. if($consult!=false){
  323. $up=Db::name("consult_info")->where(['zxNo'=>$consult['zxNo'],"is_del"=>0,"status"=>1])->select()
  324. ->toArray();
  325. if(!empty($up)){
  326. $staar=Db::name("consult_info")->where(['zxNo'=>$consult['zxNo'],"is_del"=>0,"status"=>1])->save
  327. (["status"=>2,"updatetime"=>date("Y-m-d H:i:s")]);
  328. if($staar==false){
  329. Db::rollback();
  330. return error_show(1002, "项目咨询单招标结束失败");
  331. }
  332. }
  333. }
  334. }
  335. Db::commit();
  336. return app_show(0,"反馈数据选择成功");
  337. }else{
  338. Db::rollback();
  339. return error_show(1004,"反馈数据选择失败");
  340. }
  341. }catch (\Exception $e){
  342. Db::rollback();
  343. return error_show(1004,$e->getMessage());
  344. }
  345. }
  346. public function planCheck(){
  347. $planNos = isset($this->post['planNos'])&&!empty($this->post['planNos'])? $this->post['planNos'] :"";
  348. if($planNos==""){
  349. return error_show(1004,"参数planNos不能为空");
  350. }
  351. $status=isset($this->post['status'])&&$this->post['status']!=="" ? intval($this->post['status']):"";
  352. if($status==""){
  353. return error_show(1004,"参数status不能为空");
  354. }
  355. $selec = Db::name("project_plan")->where(["planNo"=>$planNos,'is_del'=>0,"status"=>0])->select()->toArray();
  356. if(empty($selec)){
  357. return error_show(1004,"项目方案数据信息未找到");
  358. }
  359. Db::startTrans();
  360. try{
  361. $up = Db::name("project_plan")->where(["planNo"=>$planNos,'is_del'=>0,"status"=>0])->save(["status"=>1,"updatetime"=>date("Y-m-d H:i:s")]);
  362. if($up) {
  363. foreach ($selec as $value){
  364. ActionLog::logAdd(['id'=>0,"nickname"=>'客户'], [
  365. "order_code" => $value['planNo'],//项目编码
  366. "status" =>0,//这里的status是之前的值
  367. "action_remark" => '',//备注
  368. "action_type" => "edit"//新建create,编辑edit更改状态status
  369. ], "PRP", 1, ["status" =>1, "updatetime" => date("Y-m-d H:i:s")]);
  370. }
  371. $project = array_column($selec, "projectNo");
  372. if (empty($project)) {
  373. Db::rollback();
  374. return error_show(1004, "方案选择失败");
  375. }
  376. $pr=Db::name("project")->where(["projectNo" => $project, "status" => 4])->find();
  377. if($pr==false){
  378. Db::rollback();
  379. return error_show(1004, "未找到项目信息");
  380. }
  381. $pro = Db::name("project")->where($pr)->save(["status" => 5, "updatetime" => date("Y-m-d H:i:s")]);
  382. if ($pro) {
  383. ActionLog::logAdd(['id'=>0,"nickname"=>'客户'], [
  384. "order_code" => $pr['projectNo'],//项目编码
  385. "status" =>4,//这里的status是之前的值
  386. "action_remark" => '',//备注
  387. "action_type" => "edit"//新建create,编辑edit更改状态status
  388. ], "PRO", 5, ["status" => 5, "updatetime" => date("Y-m-d H:i:s")]);
  389. $process = ["order_code" => $pr['projectNo'], "order_id" => $pr['id'], "order_status" =>5, "order_type" => 'PRO',"before_status"=> $pr['status'],'holder_id'=>$pr['createrid']];
  390. ProcessOrder::AddProcess(['id'=>0,"nickname"=>'客户'], $process);
  391. Db::commit();
  392. return app_show(0, "方案数据修改成功");
  393. }
  394. }
  395. Db::rollback();
  396. return error_show(1004,"方案选择失败");
  397. }catch (\Exception $e){
  398. Db::rollback();
  399. return error_show(1004,$e->getMessage()."|".$e->getLine());
  400. }
  401. }
  402. public function outOrder(){
  403. $param =$this->request->param();
  404. $outOrdr = isset($param['outCode'])&&$param['outCode']!=''? trim($param['outCode']) :"";
  405. if($outOrdr==""){
  406. return error_show(1004,"参数 outCode 不能为空");
  407. }
  408. $outinfo =Db::name("order_out")->where(["outCode"=>$outOrdr,"is_del"=>0])
  409. ->field("orderCode,outCode,apply_id,apply_name,addrid,post_name,post_code,sendtime,send_num,remark,addtime,updatetime")->find();
  410. if($outinfo==false){
  411. return error_show(1004,"未找到发货单信息");
  412. }
  413. $addrinfo =Db::name("order_addr")->where(["id"=>$outinfo['addrid']])->field("addr,addr_code,contactor,mobile,receipt_quantity")
  414. ->find();
  415. if($addrinfo==false){
  416. return error_show(1004,"未找到发货单地址信息");
  417. }
  418. $orderinfo =Db::name("sale")->where(["orderCode"=>$outinfo["orderCode"],"is_del"=>0])
  419. ->field("good_code,good_name,addtime,order_type")->find();
  420. if($orderinfo==false){
  421. return error_show(1004,"未找到订单信息");
  422. }
  423. $postdata=[];
  424. if($outinfo['post_code']!=''){
  425. $postCode = explode(",",$outinfo['post_code']);
  426. $postinfo =Db::name("express_data")->where(["post_code"=>$postCode[0]])->find();
  427. if($postinfo['status']>0){
  428. $postdata=json_decode($postinfo['post_data'],true);
  429. }
  430. }
  431. if($orderinfo['order_type']==3){
  432. $good=Db::name("consult_bids")->where(["spuCode"=>$orderinfo['good_code'],"is_del"=>0])->find();
  433. }else{
  434. $good=Db::name("good")->where(["spuCode"=>$orderinfo['good_code'],"is_del"=>0])->find();
  435. }
  436. $info = GetInfoNoToken(["id"=>$outinfo['apply_id']]);
  437. $outinfo['apply_mobile'] ='';
  438. if($info['code']==0 && !empty($info['data'])) $outinfo['apply_mobile'] = $info['data']['mobile'] ?? '';
  439. $outinfo['addr'] = $addrinfo['addr'];
  440. $outinfo['contactor'] = $addrinfo['contactor'];
  441. $outinfo['mobile'] = $addrinfo['mobile'];
  442. $outinfo['receipt_num'] = $addrinfo['receipt_quantity'];
  443. $outinfo['good_name'] = $orderinfo['good_name'];
  444. $outinfo['good_code'] = $orderinfo['good_code'];
  445. $outinfo['order_time'] = $orderinfo['addtime'];
  446. $outinfo['post_data'] = $postdata;
  447. $outinfo['good_img'] = isset($good['good_img'])&&$good['good_img']!=""?trim($good['good_img']):"";
  448. return app_show(0,"获取成功",$outinfo);
  449. }
  450. }