Consult.php 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237
  1. <?php
  2. namespace app\abutment\controller;
  3. use app\admin\model\ActionLog;
  4. use app\admin\model\ProcessOrder;
  5. use think\facade\Db;
  6. use think\facade\Validate;
  7. class Consult extends HomeBaseController
  8. {
  9. private $noble = ['0' => '', '1' => '18K', '2' => '24K', '3' => '白银'];
  10. //招标工作台列表
  11. public function crontablist()
  12. {
  13. $this->post = $this->request->filter('trim')->post();
  14. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
  15. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
  16. //过滤贵金属相关的记录
  17. $where = [['a.is_del', "=", 0], ['b.is_del', "=", 0], ['a.cat_id', "not in", [6, 65, 88, 396, 718, 719, 819]]];
  18. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  19. if ($zxNo !== "") $where[] = ['a.zxNo', '=', $zxNo];
  20. $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
  21. if ($salesman !== "") $where[] = ["b.salesman", 'like', "%$salesman%"];
  22. $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : "";
  23. if ($cpName !== "") $where[] = ["a.good_Name", 'like', "%$cpName%"];
  24. $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
  25. if ($khNo !== "") $where[] = ["b.khNo", 'like', "%$khNo%"];
  26. $start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
  27. if ($start != "") $where[] = ["a.addtime", '>=', $start];
  28. $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] : "";
  29. if ($end != "") $where[] = ["a.addtime", '<=', $end];
  30. $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
  31. if ($status !== "") $where[] = ["a.status", '=', $status];
  32. $count = Db::name('consult_info')
  33. ->alias("a")
  34. ->leftJoin("consult_order b", "a.zxNo=b.zxNo")
  35. ->where($where)
  36. ->count();
  37. $total = ceil($count / $size);
  38. $page = $page >= $total ? $total : $page;
  39. $list = Db::name('consult_info')
  40. ->alias("a")
  41. ->leftJoin("consult_order b", "a.zxNo=b.zxNo")
  42. ->where($where)
  43. ->page($page, $size)
  44. ->field("a.*,b.createrid,b.creater,b.is_project,b.projectNo,b.khNo,b.endtime,b.platform_code,b.saleid,b.salesman,b.depart")
  45. ->select()
  46. ->toArray();
  47. $data = [];
  48. $all_cat = Db::name('cat')
  49. ->whereIn('id', array_column($list, 'cat_id'))
  50. ->column('order_rate', 'id');
  51. $all_brand = Db::name('brand')
  52. ->whereIn('id', array_column($list, 'brand_id'))
  53. ->column('brand_name', 'id');
  54. foreach ($list as $value) {
  55. $value['can'] = isset($value['cat_id']) && $value['cat_id'] != 0 ? made($value['cat_id']) : [];
  56. // $cat = Db::name("cat")->where(["id" => $value['cat_id']])->find();
  57. $budget = isset($all_cat[$value['cat_id']]) ? $all_cat[$value['cat_id']] : 0;
  58. $value['original_price'] = sprintf("%.2f", $value['budget_price'] * (1 - $budget / 100));
  59. // $brand = Db::name("brand")->where(['id' => $value['brand_id']])->find();
  60. $value['brand_name'] = isset($all_brand[$value['brand_id']]) && $all_brand[$value['brand_id']] != '' ? $all_brand[$value['brand_id']] : "";
  61. $value['khname'] = "";
  62. $value['specinfo'] = isset($value['specinfo']) && $value['specinfo'] != "" ? json_decode($value['specinfo'], true) : [];
  63. if ($value['khNo'] !== "") {
  64. $kh = Db::name("customer_info")
  65. ->where(['companyNo' => $value['khNo']])
  66. ->find();
  67. $value['khname'] = isset($kh['companyName']) ? $kh['companyName'] : "";
  68. }
  69. $consult = Db::name("consult_bids")
  70. ->where(["infoNo" => $value['infoNo'], "createrid" => $this->request->user['uid'], "is_del" => 0])
  71. ->find();
  72. $consults = Db::name("consult_bids")
  73. ->where(["infoNo" => $value['infoNo'], "is_del" => 0])
  74. ->find();
  75. $value['is_feed'] = $consult == false ? 0 : 1;
  76. $value['is_all_feed'] = $consults == false ? 0 : 1;
  77. $value['metal_name'] = isset($value['metal_id']) && $value['metal_id'] != 0 ? $this->noble[$value['metal_id']] : "";
  78. $data[] = $value;
  79. }
  80. return json_show(0, "获取成功", ['count' => $count, 'list' => $data]);
  81. }
  82. //招标工作台详情
  83. public function zxinfo()
  84. {
  85. $this->post = $this->request->filter('trim')->post();
  86. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] != "" ? trim($this->post['infoNo']) : "";
  87. if ($infoNo == "") {
  88. return json_show(1004, "参数infoNo不能为空");
  89. }
  90. $zxinfo = Db::name("consult_info")->where(["infoNo" => $infoNo, "is_del" => 0])->find();
  91. if ($zxinfo == false) {
  92. return json_show(1004, "未找到信息数据");
  93. }
  94. $zxorder = Db::name("consult_order")->where(["zxNo" => $zxinfo['zxNo'], "is_del" => 0])->find();
  95. if ($zxorder == false) {
  96. return json_show(1004, "未找到咨询信息数据");
  97. }
  98. $cat = Db::name("cat")->where(["id" => $zxinfo['cat_id']])->find();
  99. $budget = isset($cat['order_rate']) ? $cat['order_rate'] : 0;
  100. $zxinfo['can'] = isset($zxinfo['cat_id']) && $zxinfo['cat_id'] != 0 ? made($zxinfo['cat_id'], []) : [];
  101. $zxinfo['khname'] = "";
  102. $zxinfo['original_price'] = sprintf("%.2f", $zxinfo['budget_price'] * (1 - $budget / 100));
  103. $zxinfo['khNo'] = "";
  104. $zxinfo['brand_id'] = $zxinfo['brand_id'] == 0 ? "" : $zxinfo['brand_id'];
  105. $zxinfo['brand'] = "";
  106. $zxinfo['companyNo'] = isset($zxorder['companyNo']) ? $zxorder['companyNo'] : "";
  107. $zxinfo['projectNo'] = isset($zxorder['projectNo']) ? $zxorder['projectNo'] : "";
  108. $zxinfo['is_project'] = isset($zxorder['is_project']) ? $zxorder['is_project'] : "";
  109. $zxinfo['company'] = "";
  110. $zxinfo['endtime'] = isset($zxorder['endtime']) ? $zxorder['endtime'] : "";
  111. $zxinfo['platform_code'] = isset($zxorder['platform_code']) ? $zxorder['platform_code'] : "";
  112. $zxinfo['salesman'] = isset($zxorder['salesman']) ? $zxorder['salesman'] : "";
  113. $zxinfo['saleid'] = isset($zxorder['saleid']) ? $zxorder['saleid'] : "";
  114. $zxinfo['depart'] = isset($zxorder['depart']) ? $zxorder['depart'] : "";
  115. $zxinfo['project_name'] = "";
  116. $zxinfo['budget_total'] = "";
  117. $zxinfo['departinfo'] = [];
  118. $zxinfo['unit_name'] = "";
  119. $zxinfo['metal_name'] = isset($zxinfo['metal_id']) && $zxinfo['metal_id'] != 0 ? $this->noble[$zxinfo['metal_id']] : "";
  120. $zxinfo['specinfo'] = json_decode($zxinfo['specinfo'], true);
  121. if ($zxorder['khNo'] !== "") {
  122. $kh = Db::name("customer_info")->where(['companyNo' => $zxorder['khNo']])->find();
  123. $zxinfo['khname'] = isset($kh['companyName']) ? $kh['companyName'] : "";
  124. $zxinfo['khNo'] = $zxorder['khNo'];
  125. }
  126. if ($zxinfo['unit'] !== "") {
  127. $unit = Db::name("unit")->where(['id' => $zxinfo['unit']])->find();
  128. $zxinfo['unit_name'] = isset($unit['unit']) ? $unit['unit'] : "";
  129. }
  130. if ($zxinfo['brand_id'] !== "") {
  131. $unit = Db::name("brand")->where(['id' => $zxinfo['brand_id']])->find();
  132. $zxinfo['brand'] = isset($unit['brand_name']) ? $unit['brand_name'] : "";
  133. }
  134. if ($zxorder['companyNo'] !== "") {
  135. $kh = Db::name("business")->where(['companyNo' => $zxorder['companyNo']])->find();
  136. $zxinfo['company'] = isset($kh['company']) ? $kh['company'] : "";
  137. }
  138. if ($zxorder['is_project'] == 1 && $zxorder['projectNo'] !== "") {
  139. $project = Db::name("project")->where(["projectNo" => $zxorder['projectNo'], "is_del" => 0])->find();
  140. $zxinfo['project_name'] = isset($project['project_name']) ? $project['project_name'] : "";
  141. $zxinfo['budget_total'] = isset($project['budget_total']) ? $project['budget_total'] : "";
  142. $zxinfo['project_use_desc'] = isset($project['use_desc']) ? $project['use_desc'] : "";
  143. $projectinfo = Db::name("project_info")->where(["pgNo" => $zxinfo['pgNo']])->find();
  144. $zxinfo['pgNo'] = isset($projectinfo['pgNo']) ? $projectinfo['pgNo'] : "";
  145. }
  146. if ($zxorder['depart'] > 0) {
  147. $zxinfo['departinfo'] = GetPart($zxorder['depart']);
  148. }
  149. if ($zxorder['platform_code'] > 0) {
  150. $palt = Db::name("platform")->where(["id" => $zxorder['platform_code']])->find();
  151. $zxinfo['platform_name'] = isset($palt['platform_name']) ? $palt['platform_name'] : "";
  152. }
  153. return json_show(0, "获取成功", $zxinfo);
  154. }
  155. //采反商品列表
  156. public function bidlist()
  157. {
  158. $this->post = $this->request->filter('trim')->post();
  159. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
  160. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
  161. $where = [['is_del', "=", 0]];
  162. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  163. if ($zxNo !== "") {
  164. $where[] = ['zxNo', 'like', '%' . $zxNo . '%'];
  165. }
  166. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  167. if ($infoNo !== "") {
  168. $where[] = ['infoNo', 'like', '%' . $infoNo . '%'];
  169. }
  170. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
  171. if ($bidNo !== "") {
  172. $where[] = ['bidNo', 'like', '%' . $bidNo . '%'];
  173. }
  174. $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
  175. if ($pgNo !== "") {
  176. $bidinfo = Db::name("consult_info")->where([["pgNo", "=", $pgNo], ["is_del", "=", 0]])->column("infoNo");
  177. $where[] = ['infoNo', 'in', $bidinfo];
  178. }
  179. $bargain_status = isset($this->post['bargain_status']) && $this->post['bargain_status'] !== "" ? intval($this->post['bargain_status']) : "";
  180. if ($bargain_status !== "") {
  181. $bidinfo = Db::name("consult_info")->where([["bargain_status", "=", $bargain_status], ["is_del", "=", 0]])->column("infoNo");
  182. $where[] = ['infoNo', 'in', $bidinfo];
  183. }
  184. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  185. if ($projectNo !== "") {
  186. $zxlist = Db::name("consult_order")->where(["projectNo" => $projectNo, "is_del" => 0, "is_project" => 1])->column("zxNo");
  187. $where[] = ['zxNo', 'in', $zxlist];
  188. }
  189. $is_own = isset($this->post['is_own']) ? intval($this->post['is_own']) : "0";
  190. if ($is_own == 1) {
  191. // $token = isset($this->post['token']) ? trim($this->post['token']) : "";
  192. // if($token==""){
  193. // return json_show(101,'token不能为空');
  194. // }
  195. // $apply_id =GetUserInfo($token);
  196. // if(empty($apply_id)||$apply_id['code']!=0){
  197. // return json_show(1002,"申请人数据不存在");
  198. // }
  199. $rm = $this->request->user['uid'];
  200. $where[] = ['createrid', "=", $rm];
  201. }
  202. $count = Db::name('consult_bids')->where($where)->count();
  203. $total = ceil($count / $size);
  204. $page = $page >= $total ? $total : $page;
  205. $list = Db::name('consult_bids')->where($where)->page($page, $size)->select()->toArray();
  206. $data = [];
  207. foreach ($list as $value) {
  208. $catinfo = Db::name("cat")->where(["id" => $value['cat_id']])->find();
  209. $value['can'] = isset($value['cat_id']) && $value['cat_id'] != 0 ? made($value['cat_id']) : [];
  210. $unit = Db::name("unit")->where(["id" => $value['unit_id']])->find();
  211. $value['unit'] = isset($unit['unit']) ? $unit['unit'] : '';
  212. $supplier = Db::name("supplier")->where(["code" => $value['supplierNo']])->find();
  213. $value['supplierName'] = isset($supplier['name']) ? $supplier['name'] : "";
  214. if ($value['brand_id'] != 0) {
  215. $brand = Db::name("brand")->where(["id" => $value['brand_id']])->find();
  216. $value["brand_name"] = isset($brand['brand_name']) ? $brand['brand_name'] : "";
  217. } else {
  218. $value["brand_name"] = "";
  219. $value["brand_id"] = "";
  220. }
  221. $bidinfo = Db::name("consult_info")->where(["infoNo" => $value["infoNo"]])->find();
  222. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate'] : 0;
  223. $god = [
  224. "metal_id" => $value['metal_id'],
  225. "weight" => $value["good_weight"],
  226. "demo_fee" => $value["demo_fee"],
  227. "delivery_fee" => $value["delivery_fee"],
  228. "open_fee" => $value["open_fee"],
  229. "packing_fee" => $value["pakge_fee"],
  230. "mark_fee" => $value["mark_fee"],
  231. "nake_fee" => $value["nake_fee"],
  232. "cert_fee" => $value["cert_fee"],
  233. // "cost_fee"=>$value["cost_fee"],
  234. "cost_fee" => $value["sale_cost_fee"] != $value['origin_cost_fee'] ? $value["sale_cost_fee"] : $value["cost_fee"],
  235. "num" => $bidinfo["num"],
  236. ];
  237. $top_cat = made($value['cat_id']);
  238. $top_cat_id = isset($top_cat[0]['id']) ? $top_cat[0]['id'] : 0;
  239. if ($value['is_gold_price'] == 1 && $top_cat_id == 6) {
  240. $price = GoldPrice($god, $budget / 100);
  241. $value['sale_price'] = round($price, 2);
  242. $value['origin_price'] = $value["sale_cost_fee"] != $value['origin_cost_fee'] ? $value["sale_price"] :
  243. $value["origin_price"];
  244. }
  245. $value['cost_fee'] = $value['origin_cost_fee'];
  246. $value['specinfo'] = json_decode($value['specinfo'], true);
  247. $value['metal_name'] = isset($value['metal_id']) && $value['metal_id'] != 0 ? $this->noble[$value['metal_id']] : "";
  248. $value['bargain_status'] = $bidinfo['bargain_status'];
  249. //reject驳回原因,status==5表示驳回
  250. $value['reject'] = [];
  251. if ($value['status'] >= 5) {
  252. $value['reject'] = Db::name('bargain_order')
  253. ->field('id,remark,status')
  254. ->where(['infoNo' => $infoNo, 'bidsNo' => $value['bidNo']])
  255. ->whereIn('status', [3, 8, 11])->order("id desc")
  256. ->find();
  257. }
  258. //产地
  259. $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
  260. if ($value['delivery_place'] != "") {
  261. list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $value['delivery_place']);
  262. }
  263. $value['delivery_place_cn'] = GetAddr(json_encode($place));
  264. $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
  265. if ($value['origin_place'] != "") {
  266. list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $value['origin_place']);
  267. }
  268. $value['origin_addr'] = GetAddr(json_encode($place));
  269. // if($value['origin_place']!=''){
  270. // $code = explode(",",$value['origin_place']);
  271. // $temp=[];
  272. // $temp['provice_code']=isset($code[0])?$code[0]:"";
  273. // $temp['city_code']=isset($code[1])?$code[1]:"";
  274. // $temp['area_code']=isset($code[2])?$code[2]:"";
  275. // $addr= GetAddr(json_encode($temp));
  276. // $value['origin_addr'] = $addr;
  277. // }
  278. $data[] = $value;
  279. }
  280. return json_show(0, "获取成功", ['count' => $count, 'list' => $data]);
  281. }
  282. //创建采反商品
  283. public function create()
  284. {
  285. $this->post = $this->request->filter('trim')->post();
  286. $is_project = isset($this->post['is_project']) && $this->post['is_project'] !== "" ? intval($this->post['is_project']) : "";
  287. if ($is_project === "") {
  288. return json_show(1002, "参数is_project不能为空");
  289. }
  290. if ($is_project == 1) {
  291. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  292. if ($projectNo === "") {
  293. return json_show(1002, "参数projectNo不能为空");
  294. }
  295. }
  296. $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
  297. if ($khNo === "") {
  298. return json_show(1002, "参数khNo不能为空");
  299. }
  300. $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !== "" ? trim($this->post['companyNo']) : "";
  301. if ($companyNo === "") {
  302. return json_show(1002, "参数companyNo不能为空");
  303. }
  304. $endtime = isset($this->post['endtime']) && $this->post['endtime'] !== "" ? $this->post['endtime'] : "";
  305. if ($endtime === "") {
  306. return json_show(1002, "参数endtime不能为空");
  307. }
  308. $platform_code = isset($this->post['platform_code']) && $this->post['platform_code'] !== "" ? trim($this->post['platform_code']) :
  309. "";
  310. if ($platform_code === "") {
  311. return json_show(1002, "参数platform_code不能为空");
  312. }
  313. $ladder = isset($this->post['ladder']) && !empty($this->post['ladder']) ? $this->post['ladder'] : "";
  314. if ($ladder == "") {
  315. return json_show(1005, "参数ladder不能为空");
  316. }
  317. // $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  318. // if($token==''){
  319. // return json_show(105,"参数token不能为空");
  320. // }
  321. // $user =GetUserInfo($token);
  322. // if(empty($user)||$user['code']!=0){
  323. // return json_show(102,"用户数据不存在");
  324. // }
  325. $createrid = $this->request->user['uid'];
  326. $creater = $this->request->user['nickname'];
  327. $depart = Db::name("depart_user")->where(["uid" => $createrid, "status" => 1, "is_del" => 0])->find();
  328. $zxNo = makeNo("ZX");
  329. Db::startTrans();
  330. try {
  331. $data = [
  332. "zxNo" => $zxNo,
  333. "createrid" => $createrid,
  334. "creater" => $creater,
  335. "is_project" => $is_project,
  336. "projectNo" => isset($projectNo) ? $projectNo : "",
  337. "khNo" => $khNo,
  338. "companyNo" => $companyNo,
  339. "endtime" => $endtime,
  340. "salesman" => $creater,
  341. "platform_code" => $platform_code,
  342. "saleid" => $createrid,
  343. "depart" => isset($depart['itemid']) ? $depart['itemid'] : 0,
  344. "status" => 0,
  345. "is_del" => 0,
  346. "addtime" => date("Y-m-d H:i:s"),
  347. "updatetime" => date("Y-m-d H:i:s"),
  348. ];
  349. $zx = Db::name("consult_order")->insert($data);
  350. if ($zx) {
  351. //判断是否是项目,且该项目是否存在台账记录中
  352. if ($is_project == 1) $stand_exists = Db::name('standing_book')->field('id')->where('projectNo', $projectNo)->find();
  353. foreach ($ladder as $value) {
  354. $infoNo = makeNo("IF");
  355. $specinfo = [];
  356. if (isset($value['specinfo']) && !empty($value['specinfo'])) {
  357. foreach ($value["specinfo"] as $v) {
  358. $spec = Db::name("specs")->where(["id" => $v['specid']])->find();
  359. $spec_value = Db::name("spec_value")->where(["id" => $v['spec_value_id']])->find();
  360. $v['spec_name'] = isset($spec['spec_name']) ? $spec['spec_name'] : "";
  361. $v['spec_value_name'] = isset($spec_value['spec_value']) ? $spec_value['spec_value'] : "";
  362. $specinfo[] = $v;
  363. }
  364. }
  365. $info = [
  366. "infoNo" => $infoNo,
  367. "zxNo" => $zxNo,
  368. "spuCode" => "",
  369. "good_name" => $value['good_name'],
  370. "good_img" => $value['good_img'],
  371. "cat_id" => $value['cat_id'],
  372. "unit" => $value['unit'],
  373. "brand_id" => $value['brand_id'],
  374. "arrival_time" => $value['arrival_time'],
  375. "specinfo" => empty($specinfo) ? "" : json_encode($specinfo),
  376. "cost_desc" => isset($value['cost_desc']) ? $value['cost_desc'] : '',
  377. "is_addrs" => $value['is_addrs'],
  378. "is_custom" => $value['is_custom'],
  379. "metal_id" => $value['metal_id'],
  380. "config" => isset($value['config']) ? $value['config'] : "",
  381. "other_config" => isset($value['other_config']) ? $value['other_config'] : "",
  382. "specs_weight" => isset($value['specs_weight']) ? $value['specs_weight'] : "0",
  383. "gold_price" => isset($value['gold_price']) ? $value['gold_price'] : "0",
  384. "is_gold_price" => isset($value['is_gold_price']) ? $value['is_gold_price'] : "0",
  385. "total_weight" => isset($value['total_weight']) ? $value['total_weight'] : "0",
  386. "budget_price" => $value['budget_price'],
  387. "num" => $value['num'],
  388. "pgNo" => isset($value['pgNo']) && $value['pgNo'] !== "" ? trim($value['pgNo']) : "",
  389. "use_desc" => $value['use_desc'],
  390. "remark" => $value['remark'],
  391. "status" => 1,
  392. "is_del" => 0,
  393. "addtime" => date("Y-m-d H:i:s"),
  394. "updatetime" => date("Y-m-d H:i:s"),
  395. 'enclosure_file' => isset($value['enclosure_file']) ? $value['enclosure_file'] : '',
  396. ];
  397. $up = Db::name("consult_info")->insertGetId($info);
  398. if (!$up) {
  399. Db::rollback();
  400. return json_show(1004, '添加失败');
  401. } else {
  402. //修改状态
  403. ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
  404. "order_code" => $infoNo,//咨询单详情编号
  405. "status" => 1,//这里的status是之前的值
  406. "action_remark" => '',//备注
  407. "action_type" => "create"//新建create,编辑edit,更改状态status
  408. ], "ZXD", 1, $info);
  409. //竞价单不走流程,不推待办已办
  410. // ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
  411. // "order_type" => 'ZXD',
  412. // "order_code" => $infoNo,//咨询单详情编号
  413. // "order_id" => $up,
  414. // "order_status" => 1,
  415. // 'before_status'=>0
  416. // ]);
  417. //如果存在该项目编码,更新对应的第一个竞价单编码,其他竞价单编码新增(带着项目编码)
  418. if (isset($stand_exists)) {
  419. Db::name('standing_book')
  420. ->where('id', $stand_exists['id'])
  421. ->update([
  422. 'infoNo' => $infoNo,
  423. 'updatetime' => date('Y-m-d H:i:s')
  424. ]);
  425. unset($stand_exists);//后面的竞价单编码不用更新,都是新增
  426. } else {
  427. //添加台账信息
  428. Db::name('standing_book')
  429. ->insert([
  430. 'standBookNo' => makeNo("IO"),
  431. 'projectNo' => isset($projectNo) ? $projectNo : '',
  432. 'infoNo' => $infoNo,
  433. 'companyNo' => $companyNo,
  434. 'customer_code' => $khNo,
  435. 'addtime' => date('Y-m-d H:i:s'),
  436. 'updatetime' => date('Y-m-d H:i:s')
  437. ]);
  438. }
  439. }
  440. }
  441. Db::commit();
  442. return json_show(0, "新建成功", ["zxNo" => $zxNo]);
  443. } else {
  444. Db::rollback();
  445. return json_show(1004, "新建失败");
  446. }
  447. } catch (\Exception $e) {
  448. Db::rollback();
  449. return json_show(1003, $e->getMessage());
  450. }
  451. }
  452. //复制上面的bidlist方法,只更改排序方式
  453. public function bidlistCopy()
  454. {
  455. $this->post = $this->request->filter('trim')->post();
  456. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
  457. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
  458. $where = [['cb.is_del', "=", 0], ['c.status', '<>', 6]];//不要'取消转单'状态下的数据
  459. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  460. if ($zxNo !== "") {
  461. $where[] = ['cb.zxNo', 'like', '%' . $zxNo . '%'];
  462. }
  463. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  464. if ($infoNo !== "") {
  465. $where[] = ['cb.infoNo', 'like', '%' . $infoNo . '%'];
  466. }
  467. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
  468. if ($bidNo !== "") {
  469. $where[] = ['cb.bidNo', 'like', '%' . $bidNo . '%'];
  470. }
  471. $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
  472. if ($pgNo !== "") {
  473. $bidinfo = Db::name("consult_info")->where([["pgNo", "=", $pgNo], ["is_del", "=", 0]])->column("infoNo");
  474. $where[] = ['cb.infoNo', 'in', $bidinfo];
  475. }
  476. $bargain_status = isset($this->post['bargain_status']) && $this->post['bargain_status'] !== "" ? intval($this->post['bargain_status']) : "";
  477. if ($bargain_status !== "") {
  478. $bidinfo = Db::name("consult_info")->where([["bargain_status", "=", $bargain_status], ["is_del", "=", 0]])->column("infoNo");
  479. $where[] = ['cb.infoNo', 'in', $bidinfo];
  480. }
  481. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  482. if ($projectNo !== "") {
  483. $zxlist = Db::name("consult_order")->where(["projectNo" => $projectNo, "is_del" => 0, "is_project" => 1])->column
  484. ("zxNo");
  485. $where[] = ['cb.zxNo', 'in', $zxlist];
  486. }
  487. $is_own = isset($this->post['is_own']) ? intval($this->post['is_own']) : "0";
  488. if ($is_own == 1) {
  489. // $token = isset($this->post['token']) ? trim($this->post['token']) : "";
  490. // if ($token == "") {
  491. // return json_show(101, 'token不能为空');
  492. // }
  493. // $apply_id = GetUserInfo($token);
  494. // if (empty($apply_id) || $apply_id['code'] != 0) {
  495. // return json_show(1002, "申请人数据不存在");
  496. // }
  497. $where[] = ['cb.createrid', "=", $this->request->user['uid']];
  498. $where[] = ['cb.supplierNo', "=", $this->request->user['supplierNo']];
  499. }
  500. $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
  501. if ($company_name !== "") $where[] = ["cb.createrid", 'in', get_company_item_user_by_name($company_name)];
  502. $count = Db::name('consult_bids')
  503. ->alias('cb')
  504. ->leftJoin("depart_user u", "u.uid=cb.createrid AND u.is_del=0")
  505. ->leftJoin("consult_info c", "c.infoNo=cb.infoNo")
  506. ->where($where)
  507. ->count();
  508. $total = ceil($count / $size);
  509. $page = $page >= $total ? $total : $page;
  510. $list = Db::name('consult_bids')
  511. ->alias('cb')
  512. ->field('cb.*,u.itemid')
  513. ->leftJoin("depart_user u", "u.uid=cb.createrid AND u.is_del=0")
  514. ->leftJoin("consult_info c", "c.infoNo=cb.infoNo")
  515. ->where($where)
  516. ->page($page, $size)
  517. ->order('cb.addtime', 'desc')
  518. ->cursor();
  519. $data = [];
  520. foreach ($list as $value) {
  521. $catinfo = Db::name("cat")->where(["id" => $value['cat_id']])->find();
  522. $value['can'] = isset($value['cat_id']) && $value['cat_id'] != 0 ? made($value['cat_id']) : [];
  523. $unit = Db::name("unit")->where(["id" => $value['unit_id']])->find();
  524. $value['unit'] = isset($unit['unit']) ? $unit['unit'] : '';
  525. $supplier = Db::name("supplier")->where(["code" => $value['supplierNo']])->find();
  526. $value['supplierName'] = isset($supplier['name']) ? $supplier['name'] : "";
  527. if ($value['brand_id'] != 0) {
  528. $brand = Db::name("brand")->where(["id" => $value['brand_id']])->find();
  529. $value["brand_name"] = isset($brand['brand_name']) ? $brand['brand_name'] : "";
  530. } else {
  531. $value["brand_name"] = "";
  532. $value["brand_id"] = "";
  533. }
  534. $bidinfo = Db::name("consult_info")->where(["infoNo" => $value["infoNo"]])->find();
  535. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate'] : 0;
  536. $god = [
  537. "metal_id" => $value['metal_id'],
  538. "weight" => $value["good_weight"],
  539. "demo_fee" => $value["demo_fee"],
  540. "delivery_fee" => $value["delivery_fee"],
  541. "open_fee" => $value["open_fee"],
  542. "packing_fee" => $value["pakge_fee"],
  543. "mark_fee" => $value["mark_fee"],
  544. "nake_fee" => $value["nake_fee"],
  545. "cert_fee" => $value["cert_fee"],
  546. "cost_fee" => $value["sale_cost_fee"] != $value["origin_cost_fee"] ? $value["sale_cost_fee"] : $value["cost_fee"],
  547. "num" => $bidinfo["num"],
  548. ];
  549. if ($value['is_gold_price'] == 1) {
  550. $price = GoldPrice($god, $budget / 100);
  551. $value['sale_price'] = round($price, 2);
  552. }
  553. $value['cost_fee'] = $value['origin_cost_fee'];
  554. $value['specinfo'] = json_decode($value['specinfo'], true);
  555. $value['metal_name'] = isset($value['metal_id']) && $value['metal_id'] != 0 ? $this->noble[$value['metal_id']] : "";
  556. $value['bargain_status'] = $bidinfo['bargain_status'];
  557. //reject驳回原因,status==5表示驳回
  558. $value['reject'] = [];
  559. if ($value['status'] >= 5) {
  560. $value['reject'] = Db::name('bargain_order')
  561. ->field('id,remark,status')
  562. ->where(['infoNo' => $infoNo, 'bidsNo' => $value['bidNo']])
  563. ->whereIn('status', [3, 8, 11])->order("id desc")
  564. ->find();
  565. }
  566. //产地
  567. $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
  568. if ($value['delivery_place'] != "") {
  569. list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $value['delivery_place']);
  570. }
  571. $value['delivery_place_cn'] = GetAddr(json_encode($place));
  572. $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
  573. if ($value['origin_place'] != "") {
  574. list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $value['origin_place']);
  575. }
  576. $value['origin_addr'] = GetAddr(json_encode($place));
  577. // if($value['origin_place']!=''){
  578. // $code = explode(",",$value['origin_place']);
  579. // $temp=[];
  580. // $temp['provice_code']=isset($code[0])?$code[0]:"";
  581. // $temp['city_code']=isset($code[1])?$code[1]:"";
  582. // $temp['area_code']=isset($code[2])?$code[2]:"";
  583. // $addr= GetAddr(json_encode($temp));
  584. // $value['origin_addr'] = $addr;
  585. // }
  586. $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
  587. $data[] = $value;
  588. }
  589. return json_show(0, "获取成功", ['count' => $count, 'list' => $data]);
  590. }
  591. //反馈商品详情
  592. public function feadinfo()
  593. {
  594. $this->post = $this->request->filter('trim')->post();
  595. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] != "" ? trim($this->post['bidNo']) : "";
  596. if ($bidNo == "") {
  597. return json_show(1004, "参数bidNo不能为空");
  598. }
  599. $info = Db::name("consult_bids")->where(['bidNo' => $bidNo, "is_del" => 0])->find();
  600. if ($info == false) {
  601. return json_show(1004, "未找到商品数据");
  602. }
  603. $unit = Db::name("unit")->where(["id" => $info['unit_id']])->find();
  604. $info['unit'] = isset($unit['unit']) ? $unit['unit'] : '';
  605. $info['cat_info'] = made($info['cat_id'], []);
  606. $info['noble_weight'] = $info['good_weight'];
  607. $supplier = Db::name("supplier")->where(["code" => $info['supplierNo']])->find();
  608. $info['supplierName'] = isset($supplier['name']) ? $supplier['name'] : "";
  609. if ($info['brand_id'] != 0) {
  610. $brand = Db::name("brand")->where(["id" => $info['brand_id']])->find();
  611. $info["brand_name"] = isset($brand['brand_name']) ? $brand['brand_name'] : "";
  612. } else {
  613. $info["brand_name"] = "";
  614. $info["brand_id"] = "";
  615. }
  616. $catinfo = Db::name("cat")->where(["id" => $info['cat_id']])->find();
  617. $bidinfo = Db::name("consult_info")->where(["infoNo" => $info["infoNo"]])->find();
  618. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate'] : 0;
  619. $god = [
  620. "metal_id" => $info['metal_id'],
  621. "weight" => $info["good_weight"],
  622. "demo_fee" => $info["demo_fee"],
  623. "delivery_fee" => $info["delivery_fee"],
  624. "open_fee" => $info["open_fee"],
  625. "packing_fee" => $info["pakge_fee"],
  626. "mark_fee" => $info["mark_fee"],
  627. "nake_fee" => $info["nake_fee"],
  628. "cert_fee" => $info["cert_fee"],
  629. "cost_fee" => $info["cost_fee"],
  630. "num" => $bidinfo["num"],
  631. ];
  632. if ($info['is_gold_price'] == 1) {
  633. $price = GoldPrice($god, $budget / 100);
  634. $info['sale_price'] = round($price, 2);
  635. }
  636. $info['specinfo'] = json_decode($info['specinfo'], true);
  637. $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
  638. if ($info['delivery_place'] != "") {
  639. list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $info['delivery_place']);
  640. }
  641. $info['delivery_place_cn'] = GetAddr(json_encode($place));
  642. $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
  643. if ($info['origin_place'] != "") {
  644. list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $info['origin_place']);
  645. }
  646. $info['origin_place_cn'] = GetAddr(json_encode($place));
  647. $info['metal_name'] = isset($info['metal_id']) && $info['metal_id'] != 0 ? $this->noble[$info['metal_id']] : "";
  648. $bargain = Db::name("bargain_order")->where(['bidsNo' => $bidNo, "is_del" => 0])->find();
  649. $info['bargain'] = $bargain;
  650. $info['good_img'] = explode(',', $info['good_img']);
  651. return json_show(0, "获取成功", $info);
  652. }
  653. //反馈商品添加
  654. public function feadback()
  655. {
  656. $this->post = $this->request->filter('trim')->post();
  657. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] != "" ? trim($this->post['infoNo']) : "";
  658. if ($infoNo == "") {
  659. return json_show(1002, "参数infoNo不能为空");
  660. }
  661. $zxinfo = Db::name("consult_info")->where(["infoNo" => $infoNo, "is_del" => 0])->find();
  662. if ($zxinfo == false) {
  663. return json_show(1003, "未找到信息数据");
  664. }
  665. if ($zxinfo['status'] != 1) {
  666. return json_show(1004, "任务未进行");
  667. }
  668. $zx = Db::name("consult_order")->where(["zxNo" => $zxinfo['zxNo'], "is_del" => 0])->find();
  669. if ($zx == false) {
  670. return json_show(1003, "未找咨询信息数据");
  671. }
  672. $pname = isset($this->post['pname']) && $this->post['pname'] != "" ? trim($this->post['pname']) : "";
  673. if ($pname == "") {
  674. return json_show(1002, "参数pname不能为空");
  675. }
  676. $brandid = isset($this->post['brandid']) && $this->post['brandid'] != "" ? intval($this->post['brandid']) : "";
  677. $cat_id = isset($this->post['cat_id']) && $this->post['cat_id'] != "" ? trim($this->post['cat_id']) : "";
  678. if ($cat_id == "") {
  679. return json_show(1002, "参数cat_id不能为空");
  680. }
  681. $specin = isset($this->post['specinfo']) && !empty($this->post['specinfo']) ? $this->post['specinfo'] : "";
  682. if ($specin == "") {
  683. return json_show(1003, "参数specinfo不能为空");
  684. }
  685. $specinfo = [];
  686. foreach ($specin as $v) {
  687. $spec = Db::name("specs")->where(["id" => $v['specid']])->find();
  688. $spec_value = Db::name("spec_value")->where(["id" => $v['spec_value_id']])->find();
  689. $v['spec_name'] = isset($spec['spec_name']) ? $spec['spec_name'] : "";
  690. $v['spec_value_name'] = isset($spec_value['spec_value']) ? $spec_value['spec_value'] : "";
  691. $specinfo[] = $v;
  692. }
  693. $unit_id = isset($this->post['unit_id']) && $this->post['unit_id'] != "" ? intval($this->post['unit_id']) : "";
  694. $cost_desc = isset($this->post['cost_desc']) && $this->post['cost_desc'] != "" ? trim($this->post['cost_desc']) : "";
  695. $work_day = isset($this->post['work_day']) && $this->post['work_day'] != "" ? intval($this->post['work_day']) : "";
  696. $delivery_day = isset($this->post['delivery_day']) && $this->post['delivery_day'] != "" ? intval($this->post['delivery_day']) : "";
  697. $good_img = isset($this->post['good_img']) && $this->post['good_img'] != "" ? $this->post['good_img'] : [];
  698. $expire_day = isset($this->post['expire_day']) && $this->post['expire_day'] != "" ? intval($this->post['expire_day']) : "";
  699. $origin_place = isset($this->post['origin_place']) && $this->post['origin_place'] != "" ? trim($this->post['origin_place']) : "";
  700. $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo'] != "" ? trim($this->post['supplierNo']) : "";
  701. $pay_way = isset($this->post['pay_way']) && $this->post['pay_way'] != "" ? intval($this->post['pay_way']) : "";
  702. $tax = isset($this->post['tax']) && $this->post['tax'] != "" ? trim($this->post['tax']) : "";
  703. $send_way = isset($this->post['send_way']) && $this->post['send_way'] != "" ? intval($this->post['send_way']) : "";
  704. $metal_id = isset($this->post['metal_id']) && $this->post['metal_id'] != "" ? intval($this->post['metal_id']) : "0";
  705. $is_gold_price = isset($this->post['is_gold_price']) && $this->post['is_gold_price'] != "" ? intval($this->post['is_gold_price']) : "0";
  706. $config = isset($this->post['config']) && $this->post['config'] != "" ? $this->post['config'] : "";
  707. $other_config = isset($this->post['other_config']) && $this->post['other_config'] != "" ? $this->post['other_config'] : "";
  708. $weight = isset($this->post['weight']) && $this->post['weight'] !== "" ? floatval($this->post['weight']) : "0";
  709. $good_weight = isset($this->post['noble_weight']) && $this->post['noble_weight'] !== "" ? floatval($this->post['noble_weight']) : "0";
  710. $demo_fee = isset($this->post['demo_fee']) && $this->post['demo_fee'] !== "" ? floatval($this->post['demo_fee']) : "0";
  711. $delivery_fee = isset($this->post['delivery_fee']) && $this->post['delivery_fee'] !== "" ? floatval($this->post['delivery_fee']) : "0";
  712. $open_fee = isset($this->post['open_fee']) && $this->post['open_fee'] !== "" ? floatval($this->post['open_fee']) : "0";
  713. $pakge_fee = isset($this->post['pakge_fee']) && $this->post['pakge_fee'] !== "" ? floatval($this->post['pakge_fee']) : "0";
  714. $nake_fee = isset($this->post['nake_fee']) && $this->post['nake_fee'] !== "" ? floatval($this->post['nake_fee']) : "0";
  715. $mark_fee = isset($this->post['mark_fee']) && $this->post['mark_fee'] !== "" ? floatval($this->post['mark_fee']) : "0";
  716. $cert_fee = isset($this->post['cert_fee']) && $this->post['cert_fee'] !== "" ? floatval($this->post['cert_fee']) : "0";
  717. $cost_fee = isset($this->post['cost_fee']) && $this->post['cost_fee'] !== "" ? floatval($this->post['cost_fee']) : "0";
  718. if ($nake_fee === "") {
  719. return json_show(1004, "参数nake_fee不能为空");
  720. }
  721. $is_diff = isset($this->post['is_diff']) && $this->post['is_diff'] !== "" ? intval($this->post['is_diff']) : "";
  722. $supply_area = isset($this->post['supply_area']) && $this->post['supply_area'] !== "" ? intval($this->post['supply_area']) : "";
  723. $remark = isset($this->post['remark']) && $this->post['remark'] != "" ? trim($this->post['remark']) : "";
  724. $delivery_place = isset($this->post['delivery_place']) && $this->post['delivery_place'] != '' ? trim($this->post['delivery_place']) : "";
  725. if ($delivery_place == '') {
  726. return json_show(1002, "参数delivery_place不能为空");
  727. }
  728. // $token = isset($this->post['token']) && $this->post['token'] != '' ? trim($this->post['token']) : "";
  729. // if ($token == '') {
  730. // return json_show(1002, "参数token不能为空");
  731. // }
  732. // $user = GetUserInfo($token);
  733. // if (empty($user) || $user['code'] != 0) {
  734. // return json_show(1005, "用户数据不存在");
  735. // }
  736. $createrid = $this->request->user['uid'];
  737. $creater = $this->request->user['nickname'];
  738. $bidNo = makeNo("BD");
  739. $spucode = makeNo("SKU");
  740. $catinfo = Db::name("cat")->where(["id" => $cat_id])->find();
  741. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate'] / 100 : 0;
  742. //部分参数的大小校验
  743. $vali = Validate::rule([
  744. 'expire_day|有效时长' => 'require|elt:214748364',
  745. 'delivery_day|物流时长' => 'require|elt:214748364',
  746. 'work_day|生产工期' => 'require|elt:214748364',
  747. 'weight|总重量' => 'require|max:10',
  748. ]);
  749. $temp = [
  750. 'expire_day' => $expire_day,
  751. 'delivery_day' => $delivery_day,
  752. 'work_day' => $work_day,
  753. 'weight' => $weight,
  754. ];
  755. if (!$vali->check($temp)) return json_show(0, $vali->getError());
  756. $sale_cost_fee = $cost_fee;//销售工艺费默认取传值
  757. $cat_top_list = made($cat_id);
  758. $cat_top_id = isset($cat_top_list[0]['id']) ? $cat_top_list[0]['id'] : 0;
  759. if ($is_gold_price == 1 && $cat_top_id == 6) {
  760. $gold = Db::name("gold_price1")->where(["type" => $metal_id, "is_del" => 0, "status" => 1])->order("addtime desc")->find();
  761. //$total_fee = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  762. //$total_fee(成本合计初始价格) =打样费/购买数量 + 开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价0+运费;
  763. $total_fee = $demo_fee / $zxinfo['num'] + $open_fee / $zxinfo['num'] + $good_weight * $gold["price"] + $cost_fee * $good_weight + $pakge_fee + $mark_fee + $cert_fee + $nake_fee + $delivery_fee;
  764. // $saleprice = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee/(1-$budget)* $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  765. //$saleprice(最终售价) = (开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价)/(1-成本售价/100);
  766. // $saleprice = ($open_fee / $zxinfo['num'] + $weight * $gold["price"] + $cost_fee * $weight + $pakge_fee + $mark_fee + $cert_fee + $nake_fee) / (1 - $budget);
  767. $saleprice = $total_fee / (1 - $budget);
  768. //销售工艺费=((开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价)/(1-成本售价/100)-(打样费/购买数量 + 开模费/购买数量 +包装费+加标费+证书费+产品裸价0+运费) )/商品重量-最新金价
  769. $sale_cost_fee = ($saleprice - ($demo_fee / $zxinfo['num'] + $open_fee / $zxinfo['num'] + $pakge_fee + $mark_fee + $cert_fee + $nake_fee + $delivery_fee)) / $good_weight - $gold["price"];
  770. } else {
  771. if ($nake_fee) {
  772. $saleprice = ($demo_fee / $zxinfo['num'] + $delivery_fee + $open_fee / $zxinfo['num'] + $cost_fee * $good_weight + $pakge_fee + $mark_fee + $cert_fee + $nake_fee) / (1 - $budget);
  773. $total_fee = $demo_fee / $zxinfo['num'] + $delivery_fee + $open_fee / $zxinfo['num'] + $cost_fee * $good_weight + $pakge_fee + $mark_fee + $cert_fee + $nake_fee;
  774. } else {
  775. $saleprice = ($demo_fee / $zxinfo['num'] + $delivery_fee + $open_fee / $zxinfo['num'] + $cost_fee * $good_weight + $pakge_fee + $mark_fee + $cert_fee) / (1 - $budget);
  776. $total_fee = $demo_fee / $zxinfo['num'] + $delivery_fee + $open_fee / $zxinfo['num'] + $cost_fee * $good_weight + $pakge_fee + $mark_fee + $cert_fee;
  777. }
  778. }
  779. $supplier = Db::name('supplier')
  780. ->field('id,person,personid')
  781. ->where('code',$supplierNo)
  782. ->findOrEmpty();
  783. $data = [
  784. "bidNo" => $bidNo,
  785. "infoNo" => $infoNo,
  786. "zxNo" => $zxinfo['zxNo'],
  787. "spuCode" => $spucode,
  788. "good_name" => $pname,
  789. "brand_id" => $brandid,
  790. "cat_id" => $cat_id,
  791. "specinfo" => json_encode($specinfo),
  792. "unit_id" => $unit_id,
  793. "cost_desc" => $cost_desc,
  794. "work_day" => $work_day,
  795. "delivery_day" => $delivery_day,
  796. "good_img" => is_array($good_img) ? implode(',', $good_img) : $good_img,
  797. "expire_day" => $expire_day,
  798. "origin_place" => $origin_place,
  799. "supplierNo" => $supplierNo,
  800. "pay_way" => $pay_way,
  801. "tax" => $tax,
  802. "send_way" => $send_way,
  803. "metal_id" => $metal_id,
  804. "is_gold_price" => $is_gold_price,
  805. "config" => $config,
  806. "other_config" => $other_config,
  807. "weight" => $weight,
  808. "good_weight" => $good_weight,
  809. "gold_price" => isset($gold["price"]) ? $gold["price"] : 0,
  810. "is_diff" => $is_diff,
  811. "demo_fee" => $demo_fee,
  812. "delivery_fee" => $delivery_fee,
  813. "open_fee" => $open_fee,
  814. "pakge_fee" => $pakge_fee,
  815. "nake_fee" => $nake_fee,
  816. "mark_fee" => $mark_fee,
  817. "cert_fee" => $cert_fee,
  818. "cost_fee" => $cost_fee,
  819. "total_fee" => $total_fee,
  820. "supply_area" => $supply_area,
  821. "remark" => $remark,
  822. "sale_price" => $saleprice,
  823. "sale_cost_fee" => $sale_cost_fee,
  824. "origin_cost_fee" => $sale_cost_fee,
  825. "origin_price" => $saleprice,
  826. "createrid" => $createrid,
  827. "creater" => $creater,
  828. "status" => $zxinfo['status'] == 1 ? 1 : 2,
  829. "is_del" => 0,
  830. "addtime" => date("Y-m-d H:i:s"),
  831. "updatetime" => date("Y-m-d H:i:s"),
  832. 'delivery_place' => $delivery_place,//发货地
  833. 'cgder' => $supplier['person'] ?? '',
  834. 'cgderid' => $supplier['personid'] ?? 0,
  835. ];
  836. Db::startTrans();
  837. try {
  838. $insert = Db::name("consult_bids")->insert($data);
  839. if ($insert) {
  840. if ($zx['is_project'] == 1 && $zx['projectNo'] != "" && $zxinfo['pgNo'] != "") {
  841. $projectinfo = Db::name("project_info")->where(["pgNo" => $zxinfo["pgNo"], "projectNo" => $zx['projectNo'], "is_del" => 0])->find();
  842. if ($projectinfo == false) {
  843. Db::rollback();
  844. return json_show(1006, "未找到项目信息");
  845. }
  846. $temp = [];
  847. $temp['spuCode'] = $spucode;
  848. $temp['skuCode'] = "";
  849. $temp['pgNo'] = $zxinfo['pgNo'];
  850. $temp['projectNo'] = $zx['projectNo'];
  851. $temp['good_name'] = $pname;
  852. $temp['good_type'] = $projectinfo['good_type'];
  853. $temp['data_source'] = 2;
  854. $temp['cat_id'] = $cat_id;
  855. $temp['budget_price'] = $projectinfo['budget_price'];
  856. $temp['sale_price'] = $saleprice;
  857. $temp['origin_price'] = $total_fee;
  858. $temp['num'] = $zxinfo['num'];
  859. $temp['status'] = 0;
  860. $temp['is_del'] = 0;
  861. $temp['creater'] = $creater;
  862. $temp['createrid'] = $createrid;
  863. $temp['addtime'] = date("Y-m-d H:i:s");
  864. $temp['updatetime'] = date("Y-m-d H:i:s");
  865. $nu = Db::name("project_feedback")->insert($temp);
  866. if ($nu == false) {
  867. Db::rollback();
  868. return json_show(1006, "项目反馈失败");
  869. } else {
  870. $old_projectinfo_status = $projectinfo['status'];
  871. $projectinfo['status'] = 2;
  872. $projectinfo['updatetime'] = date("Y-m-d H:i:s");
  873. $up = Db::name("project_info")->save($projectinfo);
  874. if ($up) {
  875. //修改状态,添加待办,只记录动作
  876. ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
  877. "order_code" => $projectinfo['pgNo'],//编码
  878. "status" => $old_projectinfo_status,//这里的status是之前的值
  879. "action_remark" => '',//备注
  880. "action_type" => "status"//新建create,编辑edit,更改状态status
  881. ], "PRI", 2, $projectinfo);
  882. $count = Db::name("project_info")->where(["projectNo" => $projectinfo['projectNo'], "status" => 1])->count();
  883. if ($count == 0) {
  884. $projetc = Db::name("project")->where(["projectNo" => $projectinfo['projectNo'], "status" => 1])->find();
  885. if ($projetc != false) {
  886. $proc = Db::name("project")->where(["projectNo" => $projectinfo['projectNo'], "status" => 1])->save
  887. (["status" => 2, "updatetime" => date("Y-m-d H:i:s")]);
  888. if ($proc == false) {
  889. Db::rollback();
  890. return json_show(1006, "项目反馈失败");
  891. } else {
  892. //修改状态,添加待办
  893. ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
  894. "order_code" => $projetc['projectNo'],//项目编码
  895. "status" => 1,//这里的status是之前的值
  896. "action_remark" => '',//备注
  897. "action_type" => "status"//新建create,编辑edit,更改状态status
  898. ], "PRO", 2, $projetc);
  899. ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
  900. "order_type" => 'PRO',
  901. "order_code" => $projetc['projectNo'],
  902. "order_id" => $projetc['id'],
  903. "order_status" => 2,
  904. "before_status" => 1,
  905. 'holder_id'=>$projetc['createrid'],
  906. 'person_id' => Db::name('supplier')->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])->value('personid'),
  907. ]);
  908. }
  909. }
  910. }
  911. }
  912. }
  913. }
  914. Db::commit();
  915. return json_show(0, "反馈成功", ["bidNo" => $bidNo]);
  916. } else {
  917. Db::rollback();
  918. return json_show(1006, "反馈失败");
  919. }
  920. } catch (\Exception $e) {
  921. Db::rollback();
  922. return json_show(1006, $e->getMessage());
  923. }
  924. }
  925. //反馈商品编辑
  926. public function feededit()
  927. {
  928. $this->post = $this->request->filter('trim')->post();
  929. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] != "" ? trim($this->post['bidNo']) : "";
  930. if ($bidNo == "") {
  931. return json_show(1002, "参数bidNo不能为空");
  932. }
  933. $bidinfo = Db::name("consult_bids")->where(["bidNo" => $bidNo, "is_del" => 0])->find();
  934. if ($bidinfo == false) {
  935. return json_show(1003, "未找到信息数据");
  936. }
  937. if ($bidinfo['status'] >= 5) {
  938. return json_show(1004, "咨询单已确认无法修改");
  939. }
  940. $zxinfo = Db::name("consult_info")->where(["infoNo" => $bidinfo['infoNo'], "is_del" => 0])->find();
  941. if ($zxinfo == false) {
  942. return json_show(1003, "未找到信息数据");
  943. }
  944. $zx = Db::name("consult_order")->where(["zxNo" => $zxinfo['zxNo'], "is_del" => 0])->find();
  945. if ($zx == false) {
  946. return json_show(1003, "未找咨询信息数据");
  947. }
  948. $pname = isset($this->post['pname']) && $this->post['pname'] != "" ? trim($this->post['pname']) : "";
  949. if ($pname == "") {
  950. return json_show(1002, "参数pname不能为空");
  951. }
  952. $brandid = isset($this->post['brandid']) && $this->post['brandid'] != "" ? intval($this->post['brandid']) : "";
  953. // if($brandid==""){
  954. // return json_show(1002,"参数brandid不能为空");
  955. // }
  956. $cat_id = isset($this->post['cat_id']) && $this->post['cat_id'] != "" ? trim($this->post['cat_id']) : "";
  957. if ($cat_id == "") {
  958. return json_show(1002, "参数cat_id不能为空");
  959. }
  960. $specin = isset($this->post['specinfo']) && !empty($this->post['specinfo']) ? $this->post['specinfo'] : "";
  961. if ($specin == "") {
  962. return json_show(1003, "参数specinfo不能为空");
  963. }
  964. $specinfo = [];
  965. foreach ($specin as $v) {
  966. $spec = Db::name("specs")->where(["id" => $v['specid']])->find();
  967. $spec_value = Db::name("spec_value")->where(["id" => $v['spec_value_id']])->find();
  968. $v['spec_name'] = isset($spec['spec_name']) ? $spec['spec_name'] : "";
  969. $v['spec_value_name'] = isset($spec_value['spec_value']) ? $spec_value['spec_value'] : "";
  970. $specinfo[] = $v;
  971. }
  972. $unit_id = isset($this->post['unit_id']) && $this->post['unit_id'] != "" ? intval($this->post['unit_id']) : "";
  973. $cost_desc = isset($this->post['cost_desc']) && $this->post['cost_desc'] != "" ? trim($this->post['cost_desc']) : "";
  974. $work_day = isset($this->post['work_day']) && $this->post['work_day'] != "" ? intval($this->post['work_day']) : "";
  975. $delivery_day = isset($this->post['delivery_day']) && $this->post['delivery_day'] != "" ? intval($this->post['delivery_day']) : "";
  976. $good_img = isset($this->post['good_img']) && $this->post['good_img'] != "" ? $this->post['good_img'] : [];
  977. $expire_day = isset($this->post['expire_day']) && $this->post['expire_day'] != "" ? intval($this->post['expire_day']) : "";
  978. $origin_place = isset($this->post['origin_place']) && $this->post['origin_place'] != "" ? trim($this->post['origin_place']) : "";
  979. $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo'] != "" ? trim($this->post['supplierNo']) : "";
  980. $pay_way = isset($this->post['pay_way']) && $this->post['pay_way'] != "" ? intval($this->post['pay_way']) : "";
  981. $tax = isset($this->post['tax']) && $this->post['tax'] != "" ? trim($this->post['tax']) : "";
  982. $send_way = isset($this->post['send_way']) && $this->post['send_way'] != "" ? intval($this->post['send_way']) : "0";
  983. $metal_id = isset($this->post['metal_id']) && $this->post['metal_id'] != "" ? intval($this->post['metal_id']) : "0";
  984. $is_gold_price = isset($this->post['is_gold_price']) && $this->post['is_gold_price'] != "" ? intval($this->post['is_gold_price']) : "0";
  985. $config = isset($this->post['config']) && $this->post['config'] != "" ? $this->post['config'] : "";
  986. $other_config = isset($this->post['other_config']) && $this->post['other_config'] != "" ? $this->post['other_config'] : "";
  987. $weight = isset($this->post['weight']) && $this->post['weight'] != "" ? floatval($this->post['weight']) : "0";
  988. $noble_weight = isset($this->post['noble_weight']) && $this->post['noble_weight'] != "" ? floatval($this->post['noble_weight']) : "0";
  989. $demo_fee = isset($this->post['demo_fee']) && $this->post['demo_fee'] != "" ? floatval($this->post['demo_fee']) : "0";
  990. $delivery_fee = isset($this->post['delivery_fee']) && $this->post['delivery_fee'] != "" ? floatval($this->post['delivery_fee']) : "0";
  991. $open_fee = isset($this->post['open_fee']) && $this->post['open_fee'] != "" ? floatval($this->post['open_fee']) : "0";
  992. $pakge_fee = isset($this->post['pakge_fee']) && $this->post['pakge_fee'] != "" ? floatval($this->post['pakge_fee']) : "0";
  993. $nake_fee = isset($this->post['nake_fee']) && $this->post['nake_fee'] !== "" ? floatval($this->post['nake_fee']) : 0;
  994. $mark_fee = isset($this->post['mark_fee']) && $this->post['mark_fee'] != "" ? floatval($this->post['mark_fee']) : "0";
  995. $cert_fee = isset($this->post['cert_fee']) && $this->post['cert_fee'] != "" ? floatval($this->post['cert_fee']) : "0";
  996. $cost_fee = isset($this->post['cost_fee']) && $this->post['cost_fee'] != "" ? floatval($this->post['cost_fee']) : "0";
  997. $is_diff = isset($this->post['is_diff']) && $this->post['is_diff'] !== "" ? intval($this->post['is_diff']) : "";
  998. $supply_area = isset($this->post['supply_area']) && $this->post['supply_area'] !== "" ? intval($this->post['supply_area']) : "";
  999. $remark = isset($this->post['remark']) && $this->post['remark'] != "" ? trim($this->post['remark']) : "";
  1000. $delivery_place = isset($this->post['delivery_place']) && $this->post['delivery_place'] != '' ? trim($this->post['delivery_place']) : "";
  1001. if ($delivery_place == '') {
  1002. return json_show(1002, "参数delivery_place不能为空");
  1003. }
  1004. $catinfo = Db::name("cat")->where(["id" => $cat_id])->find();
  1005. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate'] / 100 : 0;
  1006. $sale_cost_fee = $bidinfo['sale_cost_fee'];
  1007. $cat_top_list = made($cat_id);
  1008. $cat_top_id = isset($cat_top_list[0]['id']) ? $cat_top_list[0]['id'] : 0;
  1009. if ($is_gold_price == 1 && $cat_top_id == 6) {
  1010. $gold = Db::name("gold_price1")->where(["type" => $metal_id, "is_del" => 0, "status" => 1])->order("addtime desc")->find();
  1011. //$total_fee(成本合计初始价格) =打样费/购买数量 + 开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价0+运费;
  1012. $total_fee = $demo_fee / $zxinfo['num'] + $open_fee / $zxinfo['num'] + $noble_weight * $gold["price"] + $cost_fee * $noble_weight + $pakge_fee + $mark_fee + $cert_fee + $nake_fee + $delivery_fee;
  1013. // $saleprice = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee/(1-$budget)* $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  1014. //$saleprice(最终售价) = (开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价)/(1-成本售价/100);
  1015. $saleprice = $total_fee / (1 - $budget);
  1016. //销售工艺费=((开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价)/(1-成本售价/100)-(打样费/购买数量 + 开模费/购买数量 +包装费+加标费+证书费+产品裸价0+运费) )/商品重量-最新金价
  1017. $sale_cost_fee = ($saleprice - ($demo_fee / $zxinfo['num'] + $open_fee / $zxinfo['num'] + $pakge_fee + $mark_fee + $cert_fee + $nake_fee + $delivery_fee)) / $noble_weight - $gold["price"];
  1018. } else {
  1019. $saleprice = ($demo_fee / $zxinfo['num'] + $delivery_fee + $open_fee / $zxinfo['num'] + $cost_fee * $noble_weight + $pakge_fee + $mark_fee + $cert_fee + $nake_fee) / (1 - $budget);
  1020. $total_fee = $demo_fee / $zxinfo['num'] + $delivery_fee + $open_fee / $zxinfo['num'] + $cost_fee * $noble_weight + $pakge_fee + $mark_fee + $cert_fee + $nake_fee;
  1021. }
  1022. Db::startTrans();
  1023. try {
  1024. $createrid = $this->request->user['uid'];
  1025. $creater = $this->request->user['nickname'];
  1026. $data = [
  1027. "good_name" => $pname,
  1028. "brand_id" => $brandid,
  1029. "cat_id" => $cat_id,
  1030. "specinfo" => json_encode($specinfo),
  1031. // "material"=>$material,
  1032. "unit_id" => $unit_id,
  1033. "cost_desc" => $cost_desc,
  1034. "work_day" => $work_day,
  1035. "delivery_day" => $delivery_day,
  1036. "good_img" => is_array($good_img) ? implode(',', $good_img) : $good_img,
  1037. "expire_day" => $expire_day,
  1038. "origin_place" => $origin_place,
  1039. "supplierNo" => $supplierNo,
  1040. "pay_way" => $pay_way,
  1041. "tax" => $tax,
  1042. "send_way" => $send_way,
  1043. "metal_id" => $metal_id,
  1044. "is_gold_price" => $is_gold_price,
  1045. "config" => $config,
  1046. "other_config" => $other_config,
  1047. "weight" => $weight,
  1048. "good_weight" => $noble_weight,
  1049. "is_diff" => $is_diff,
  1050. "demo_fee" => $demo_fee,
  1051. "gold_price" => isset($gold["price"]) ? $gold["price"] : 0,
  1052. "delivery_fee" => $delivery_fee,
  1053. "open_fee" => $open_fee,
  1054. "pakge_fee" => $pakge_fee,
  1055. "nake_fee" => $nake_fee,
  1056. "mark_fee" => $mark_fee,
  1057. "cert_fee" => $cert_fee,
  1058. "cost_fee" => $cost_fee,
  1059. "sale_cost_fee" => $sale_cost_fee,
  1060. "origin_cost_fee" => $sale_cost_fee,
  1061. "total_fee" => $total_fee,
  1062. "sale_price" => $saleprice,
  1063. "origin_price" => $saleprice,
  1064. "supply_area" => $supply_area,
  1065. "remark" => $remark,
  1066. "status" => 0,
  1067. "updatetime" => date("Y-m-d H:i:s"),
  1068. 'delivery_place' => $delivery_place
  1069. ];
  1070. $insert = Db::name("consult_bids")->where($bidinfo)->save($data);
  1071. if ($insert) {
  1072. if ($zxinfo['bargain_status'] == 1) {
  1073. $zxinfo['bargain_status'] = 0;
  1074. $infoip = Db::name("consult_info")->save($zxinfo);
  1075. if ($infoip == false) {
  1076. Db::rollback();
  1077. return json_show(1006, "咨询信息状态更新失败");
  1078. }
  1079. }
  1080. if ($zx['is_project'] == 1 && $zx['projectNo'] != "" && $zxinfo['pgNo'] != "") {
  1081. $projectinfo = Db::name("project_info")->where(["pgNo" => $zxinfo["pgNo"], "projectNo" => $zx['projectNo'], "is_del" => 0])->find();
  1082. if ($projectinfo == false) {
  1083. Db::rollback();
  1084. return json_show(1006, "未找到项目信息");
  1085. }
  1086. $feed = Db::name("project_feedback")->where(["pgNo" => $zxinfo["pgNo"], "projectNo" => $zx['projectNo'], "spuCode" => $bidinfo['spuCode'], "is_del" => 0])->find();
  1087. if ($feed != false) {
  1088. $feed['good_name'] = $pname;
  1089. $feed['good_type'] = $projectinfo['good_type'];
  1090. $feed['cat_id'] = $cat_id;
  1091. $feed['sale_price'] = $saleprice;
  1092. $feed['origin_price'] = $total_fee;
  1093. $feed['updatetime'] = date("Y-m-d H:i:s");
  1094. $temp['updatetime'] = date("Y-m-d H:i:s");
  1095. $nu = Db::name("project_feedback")->save($feed);
  1096. if ($nu == false) {
  1097. Db::rollback();
  1098. return json_show(1006, "项目反馈失败");
  1099. } else {
  1100. $old_projectinfo_status = $projectinfo['status'];
  1101. $projectinfo['status'] = 2;
  1102. $projectinfo['updatetime'] = date("Y-m-d H:i:s");
  1103. $up = Db::name("project_info")->save($projectinfo);
  1104. if ($up) {
  1105. //修改状态,添加待办,只记录动作
  1106. ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
  1107. "order_code" => $projectinfo['pgNo'],//编码
  1108. "status" => $old_projectinfo_status,//这里的status是之前的值
  1109. "action_remark" => '',//备注
  1110. "action_type" => "status"//新建create,编辑edit,更改状态status
  1111. ], "PRI", 2, $projectinfo
  1112. );
  1113. $count = Db::name("project_info")->where(["projectNo" => $projectinfo['projectNo'], "status" => 1])->count();
  1114. if ($count == 0) {
  1115. //先查询是否存在status==1的项目,有的话再更新,否则跳过
  1116. $project_id = Db::name("project")->where(["projectNo" => $projectinfo['projectNo'], "status" => 1])->field('id,createrid')->findOrEmpty();
  1117. if ($project_id) {
  1118. $proc = Db::name("project")->where(["id" => $project_id['id']])->update(["status" => 2, "updatetime" => date("Y-m-d H:i:s")]);
  1119. if ($proc == false) {
  1120. Db::rollback();
  1121. return json_show(1006, "项目反馈失败");
  1122. } else {
  1123. //修改状态,添加待办
  1124. ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
  1125. "order_code" => $projectinfo['projectNo'],//项目编码
  1126. "status" => 1,//这里的status是之前的值
  1127. "action_remark" => '',//备注
  1128. "action_type" => "status"//新建create,编辑edit,更改状态status
  1129. ], "PRO", 2, $this->post);
  1130. ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
  1131. "order_type" => 'PRO',
  1132. "order_code" => $projectinfo['projectNo'],
  1133. "order_id" => $project_id['id'],
  1134. "order_status" => 2,
  1135. "before_status" => 1,
  1136. 'holder_id'=>$project_id['createrid'],
  1137. 'person_id' => Db::name('supplier')->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])->value('personid'),
  1138. ]
  1139. );
  1140. }
  1141. }
  1142. }
  1143. }
  1144. }
  1145. }
  1146. }
  1147. Db::commit();
  1148. return json_show(0, "编辑成功");
  1149. } else {
  1150. Db::rollback();
  1151. return json_show(1004, "编辑失败");
  1152. }
  1153. } catch (\Exception $e) {
  1154. Db::rollback();
  1155. return json_show(1004, $e->getMessage());
  1156. }
  1157. }
  1158. }