Consult.php 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239
  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. $relaComNo = isset($this->post['relaComNo']) && $this->post['relaComNo']!="" ? trim($this->post['relaComNo']):"";
  503. if($relaComNo!="") $where[]=['cb.supplierNo','=', $relaComNo];
  504. $count = Db::name('consult_bids')
  505. ->alias('cb')
  506. ->leftJoin("depart_user u", "u.uid=cb.createrid AND u.is_del=0")
  507. ->leftJoin("consult_info c", "c.infoNo=cb.infoNo")
  508. ->where($where)
  509. ->count();
  510. $total = ceil($count / $size);
  511. $page = $page >= $total ? $total : $page;
  512. $list = Db::name('consult_bids')
  513. ->alias('cb')
  514. ->field('cb.*,u.itemid')
  515. ->leftJoin("depart_user u", "u.uid=cb.createrid AND u.is_del=0")
  516. ->leftJoin("consult_info c", "c.infoNo=cb.infoNo")
  517. ->where($where)
  518. ->page($page, $size)
  519. ->order('cb.addtime', 'desc')
  520. ->cursor();
  521. $data = [];
  522. foreach ($list as $value) {
  523. $catinfo = Db::name("cat")->where(["id" => $value['cat_id']])->find();
  524. $value['can'] = isset($value['cat_id']) && $value['cat_id'] != 0 ? made($value['cat_id']) : [];
  525. $unit = Db::name("unit")->where(["id" => $value['unit_id']])->find();
  526. $value['unit'] = isset($unit['unit']) ? $unit['unit'] : '';
  527. $supplier = Db::name("supplier")->where(["code" => $value['supplierNo']])->find();
  528. $value['supplierName'] = isset($supplier['name']) ? $supplier['name'] : "";
  529. if ($value['brand_id'] != 0) {
  530. $brand = Db::name("brand")->where(["id" => $value['brand_id']])->find();
  531. $value["brand_name"] = isset($brand['brand_name']) ? $brand['brand_name'] : "";
  532. } else {
  533. $value["brand_name"] = "";
  534. $value["brand_id"] = "";
  535. }
  536. $bidinfo = Db::name("consult_info")->where(["infoNo" => $value["infoNo"]])->find();
  537. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate'] : 0;
  538. $god = [
  539. "metal_id" => $value['metal_id'],
  540. "weight" => $value["good_weight"],
  541. "demo_fee" => $value["demo_fee"],
  542. "delivery_fee" => $value["delivery_fee"],
  543. "open_fee" => $value["open_fee"],
  544. "packing_fee" => $value["pakge_fee"],
  545. "mark_fee" => $value["mark_fee"],
  546. "nake_fee" => $value["nake_fee"],
  547. "cert_fee" => $value["cert_fee"],
  548. "cost_fee" => $value["sale_cost_fee"] != $value["origin_cost_fee"] ? $value["sale_cost_fee"] : $value["cost_fee"],
  549. "num" => $bidinfo["num"],
  550. ];
  551. if ($value['is_gold_price'] == 1) {
  552. $price = GoldPrice($god, $budget / 100);
  553. $value['sale_price'] = round($price, 2);
  554. }
  555. $value['cost_fee'] = $value['origin_cost_fee'];
  556. $value['specinfo'] = json_decode($value['specinfo'], true);
  557. $value['metal_name'] = isset($value['metal_id']) && $value['metal_id'] != 0 ? $this->noble[$value['metal_id']] : "";
  558. $value['bargain_status'] = $bidinfo['bargain_status'];
  559. //reject驳回原因,status==5表示驳回
  560. $value['reject'] = [];
  561. if ($value['status'] >= 5) {
  562. $value['reject'] = Db::name('bargain_order')
  563. ->field('id,remark,status')
  564. ->where(['infoNo' => $infoNo, 'bidsNo' => $value['bidNo']])
  565. ->whereIn('status', [3, 8, 11])->order("id desc")
  566. ->find();
  567. }
  568. //产地
  569. $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
  570. if ($value['delivery_place'] != "") {
  571. list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $value['delivery_place']);
  572. }
  573. $value['delivery_place_cn'] = GetAddr(json_encode($place));
  574. $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
  575. if ($value['origin_place'] != "") {
  576. list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $value['origin_place']);
  577. }
  578. $value['origin_addr'] = GetAddr(json_encode($place));
  579. // if($value['origin_place']!=''){
  580. // $code = explode(",",$value['origin_place']);
  581. // $temp=[];
  582. // $temp['provice_code']=isset($code[0])?$code[0]:"";
  583. // $temp['city_code']=isset($code[1])?$code[1]:"";
  584. // $temp['area_code']=isset($code[2])?$code[2]:"";
  585. // $addr= GetAddr(json_encode($temp));
  586. // $value['origin_addr'] = $addr;
  587. // }
  588. $value['company_name'] = implode('/', array_column(GetPart($value['itemid']), 'name'));
  589. $data[] = $value;
  590. }
  591. return json_show(0, "获取成功", ['count' => $count, 'list' => $data]);
  592. }
  593. //反馈商品详情
  594. public function feadinfo()
  595. {
  596. $this->post = $this->request->filter('trim')->post();
  597. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] != "" ? trim($this->post['bidNo']) : "";
  598. if ($bidNo == "") {
  599. return json_show(1004, "参数bidNo不能为空");
  600. }
  601. $info = Db::name("consult_bids")->where(['bidNo' => $bidNo, "is_del" => 0])->find();
  602. if ($info == false) {
  603. return json_show(1004, "未找到商品数据");
  604. }
  605. $unit = Db::name("unit")->where(["id" => $info['unit_id']])->find();
  606. $info['unit'] = isset($unit['unit']) ? $unit['unit'] : '';
  607. $info['cat_info'] = made($info['cat_id'], []);
  608. $info['noble_weight'] = $info['good_weight'];
  609. $supplier = Db::name("supplier")->where(["code" => $info['supplierNo']])->find();
  610. $info['supplierName'] = isset($supplier['name']) ? $supplier['name'] : "";
  611. if ($info['brand_id'] != 0) {
  612. $brand = Db::name("brand")->where(["id" => $info['brand_id']])->find();
  613. $info["brand_name"] = isset($brand['brand_name']) ? $brand['brand_name'] : "";
  614. } else {
  615. $info["brand_name"] = "";
  616. $info["brand_id"] = "";
  617. }
  618. $catinfo = Db::name("cat")->where(["id" => $info['cat_id']])->find();
  619. $bidinfo = Db::name("consult_info")->where(["infoNo" => $info["infoNo"]])->find();
  620. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate'] : 0;
  621. $god = [
  622. "metal_id" => $info['metal_id'],
  623. "weight" => $info["good_weight"],
  624. "demo_fee" => $info["demo_fee"],
  625. "delivery_fee" => $info["delivery_fee"],
  626. "open_fee" => $info["open_fee"],
  627. "packing_fee" => $info["pakge_fee"],
  628. "mark_fee" => $info["mark_fee"],
  629. "nake_fee" => $info["nake_fee"],
  630. "cert_fee" => $info["cert_fee"],
  631. "cost_fee" => $info["cost_fee"],
  632. "num" => $bidinfo["num"],
  633. ];
  634. if ($info['is_gold_price'] == 1) {
  635. $price = GoldPrice($god, $budget / 100);
  636. $info['sale_price'] = round($price, 2);
  637. }
  638. $info['specinfo'] = json_decode($info['specinfo'], true);
  639. $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
  640. if ($info['delivery_place'] != "") {
  641. list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $info['delivery_place']);
  642. }
  643. $info['delivery_place_cn'] = GetAddr(json_encode($place));
  644. $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
  645. if ($info['origin_place'] != "") {
  646. list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $info['origin_place']);
  647. }
  648. $info['origin_place_cn'] = GetAddr(json_encode($place));
  649. $info['metal_name'] = isset($info['metal_id']) && $info['metal_id'] != 0 ? $this->noble[$info['metal_id']] : "";
  650. $bargain = Db::name("bargain_order")->where(['bidsNo' => $bidNo, "is_del" => 0])->find();
  651. $info['bargain'] = $bargain;
  652. $info['good_img'] = explode(',', $info['good_img']);
  653. return json_show(0, "获取成功", $info);
  654. }
  655. //反馈商品添加
  656. public function feadback()
  657. {
  658. $this->post = $this->request->filter('trim')->post();
  659. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] != "" ? trim($this->post['infoNo']) : "";
  660. if ($infoNo == "") {
  661. return json_show(1002, "参数infoNo不能为空");
  662. }
  663. $zxinfo = Db::name("consult_info")->where(["infoNo" => $infoNo, "is_del" => 0])->find();
  664. if ($zxinfo == false) {
  665. return json_show(1003, "未找到信息数据");
  666. }
  667. if ($zxinfo['status'] != 1) {
  668. return json_show(1004, "任务未进行");
  669. }
  670. $zx = Db::name("consult_order")->where(["zxNo" => $zxinfo['zxNo'], "is_del" => 0])->find();
  671. if ($zx == false) {
  672. return json_show(1003, "未找咨询信息数据");
  673. }
  674. $pname = isset($this->post['pname']) && $this->post['pname'] != "" ? trim($this->post['pname']) : "";
  675. if ($pname == "") {
  676. return json_show(1002, "参数pname不能为空");
  677. }
  678. $brandid = isset($this->post['brandid']) && $this->post['brandid'] != "" ? intval($this->post['brandid']) : "";
  679. $cat_id = isset($this->post['cat_id']) && $this->post['cat_id'] != "" ? trim($this->post['cat_id']) : "";
  680. if ($cat_id == "") {
  681. return json_show(1002, "参数cat_id不能为空");
  682. }
  683. $specin = isset($this->post['specinfo']) && !empty($this->post['specinfo']) ? $this->post['specinfo'] : "";
  684. if ($specin == "") {
  685. return json_show(1003, "参数specinfo不能为空");
  686. }
  687. $specinfo = [];
  688. foreach ($specin as $v) {
  689. $spec = Db::name("specs")->where(["id" => $v['specid']])->find();
  690. $spec_value = Db::name("spec_value")->where(["id" => $v['spec_value_id']])->find();
  691. $v['spec_name'] = isset($spec['spec_name']) ? $spec['spec_name'] : "";
  692. $v['spec_value_name'] = isset($spec_value['spec_value']) ? $spec_value['spec_value'] : "";
  693. $specinfo[] = $v;
  694. }
  695. $unit_id = isset($this->post['unit_id']) && $this->post['unit_id'] != "" ? intval($this->post['unit_id']) : "";
  696. $cost_desc = isset($this->post['cost_desc']) && $this->post['cost_desc'] != "" ? trim($this->post['cost_desc']) : "";
  697. $work_day = isset($this->post['work_day']) && $this->post['work_day'] != "" ? intval($this->post['work_day']) : "";
  698. $delivery_day = isset($this->post['delivery_day']) && $this->post['delivery_day'] != "" ? intval($this->post['delivery_day']) : "";
  699. $good_img = isset($this->post['good_img']) && $this->post['good_img'] != "" ? $this->post['good_img'] : [];
  700. $expire_day = isset($this->post['expire_day']) && $this->post['expire_day'] != "" ? intval($this->post['expire_day']) : "";
  701. $origin_place = isset($this->post['origin_place']) && $this->post['origin_place'] != "" ? trim($this->post['origin_place']) : "";
  702. $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo'] != "" ? trim($this->post['supplierNo']) : "";
  703. $pay_way = isset($this->post['pay_way']) && $this->post['pay_way'] != "" ? intval($this->post['pay_way']) : "";
  704. $tax = isset($this->post['tax']) && $this->post['tax'] != "" ? trim($this->post['tax']) : "";
  705. $send_way = isset($this->post['send_way']) && $this->post['send_way'] != "" ? intval($this->post['send_way']) : "";
  706. $metal_id = isset($this->post['metal_id']) && $this->post['metal_id'] != "" ? intval($this->post['metal_id']) : "0";
  707. $is_gold_price = isset($this->post['is_gold_price']) && $this->post['is_gold_price'] != "" ? intval($this->post['is_gold_price']) : "0";
  708. $config = isset($this->post['config']) && $this->post['config'] != "" ? $this->post['config'] : "";
  709. $other_config = isset($this->post['other_config']) && $this->post['other_config'] != "" ? $this->post['other_config'] : "";
  710. $weight = isset($this->post['weight']) && $this->post['weight'] !== "" ? floatval($this->post['weight']) : "0";
  711. $good_weight = isset($this->post['noble_weight']) && $this->post['noble_weight'] !== "" ? floatval($this->post['noble_weight']) : "0";
  712. $demo_fee = isset($this->post['demo_fee']) && $this->post['demo_fee'] !== "" ? floatval($this->post['demo_fee']) : "0";
  713. $delivery_fee = isset($this->post['delivery_fee']) && $this->post['delivery_fee'] !== "" ? floatval($this->post['delivery_fee']) : "0";
  714. $open_fee = isset($this->post['open_fee']) && $this->post['open_fee'] !== "" ? floatval($this->post['open_fee']) : "0";
  715. $pakge_fee = isset($this->post['pakge_fee']) && $this->post['pakge_fee'] !== "" ? floatval($this->post['pakge_fee']) : "0";
  716. $nake_fee = isset($this->post['nake_fee']) && $this->post['nake_fee'] !== "" ? floatval($this->post['nake_fee']) : "0";
  717. $mark_fee = isset($this->post['mark_fee']) && $this->post['mark_fee'] !== "" ? floatval($this->post['mark_fee']) : "0";
  718. $cert_fee = isset($this->post['cert_fee']) && $this->post['cert_fee'] !== "" ? floatval($this->post['cert_fee']) : "0";
  719. $cost_fee = isset($this->post['cost_fee']) && $this->post['cost_fee'] !== "" ? floatval($this->post['cost_fee']) : "0";
  720. if ($nake_fee === "") {
  721. return json_show(1004, "参数nake_fee不能为空");
  722. }
  723. $is_diff = isset($this->post['is_diff']) && $this->post['is_diff'] !== "" ? intval($this->post['is_diff']) : "";
  724. $supply_area = isset($this->post['supply_area']) && $this->post['supply_area'] !== "" ? intval($this->post['supply_area']) : "";
  725. $remark = isset($this->post['remark']) && $this->post['remark'] != "" ? trim($this->post['remark']) : "";
  726. $delivery_place = isset($this->post['delivery_place']) && $this->post['delivery_place'] != '' ? trim($this->post['delivery_place']) : "";
  727. if ($delivery_place == '') {
  728. return json_show(1002, "参数delivery_place不能为空");
  729. }
  730. // $token = isset($this->post['token']) && $this->post['token'] != '' ? trim($this->post['token']) : "";
  731. // if ($token == '') {
  732. // return json_show(1002, "参数token不能为空");
  733. // }
  734. // $user = GetUserInfo($token);
  735. // if (empty($user) || $user['code'] != 0) {
  736. // return json_show(1005, "用户数据不存在");
  737. // }
  738. $createrid = $this->request->user['uid'];
  739. $creater = $this->request->user['nickname'];
  740. $bidNo = makeNo("BD");
  741. $spucode = makeNo("SKU");
  742. $catinfo = Db::name("cat")->where(["id" => $cat_id])->find();
  743. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate'] / 100 : 0;
  744. //部分参数的大小校验
  745. $vali = Validate::rule([
  746. 'expire_day|有效时长' => 'require|elt:214748364',
  747. 'delivery_day|物流时长' => 'require|elt:214748364',
  748. 'work_day|生产工期' => 'require|elt:214748364',
  749. 'weight|总重量' => 'require|max:10',
  750. ]);
  751. $temp = [
  752. 'expire_day' => $expire_day,
  753. 'delivery_day' => $delivery_day,
  754. 'work_day' => $work_day,
  755. 'weight' => $weight,
  756. ];
  757. if (!$vali->check($temp)) return json_show(0, $vali->getError());
  758. $sale_cost_fee = $cost_fee;//销售工艺费默认取传值
  759. $cat_top_list = made($cat_id);
  760. $cat_top_id = isset($cat_top_list[0]['id']) ? $cat_top_list[0]['id'] : 0;
  761. if ($is_gold_price == 1 && $cat_top_id == 6) {
  762. $gold = Db::name("gold_price1")->where(["type" => $metal_id, "is_del" => 0, "status" => 1])->order("addtime desc")->find();
  763. //$total_fee = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  764. //$total_fee(成本合计初始价格) =打样费/购买数量 + 开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价0+运费;
  765. $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;
  766. // $saleprice = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee/(1-$budget)* $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  767. //$saleprice(最终售价) = (开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价)/(1-成本售价/100);
  768. // $saleprice = ($open_fee / $zxinfo['num'] + $weight * $gold["price"] + $cost_fee * $weight + $pakge_fee + $mark_fee + $cert_fee + $nake_fee) / (1 - $budget);
  769. $saleprice = $total_fee / (1 - $budget);
  770. //销售工艺费=((开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价)/(1-成本售价/100)-(打样费/购买数量 + 开模费/购买数量 +包装费+加标费+证书费+产品裸价0+运费) )/商品重量-最新金价
  771. $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"];
  772. } else {
  773. if ($nake_fee) {
  774. $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);
  775. $total_fee = $demo_fee / $zxinfo['num'] + $delivery_fee + $open_fee / $zxinfo['num'] + $cost_fee * $good_weight + $pakge_fee + $mark_fee + $cert_fee + $nake_fee;
  776. } else {
  777. $saleprice = ($demo_fee / $zxinfo['num'] + $delivery_fee + $open_fee / $zxinfo['num'] + $cost_fee * $good_weight + $pakge_fee + $mark_fee + $cert_fee) / (1 - $budget);
  778. $total_fee = $demo_fee / $zxinfo['num'] + $delivery_fee + $open_fee / $zxinfo['num'] + $cost_fee * $good_weight + $pakge_fee + $mark_fee + $cert_fee;
  779. }
  780. }
  781. $supplier = Db::name('supplier')
  782. ->field('id,person,personid')
  783. ->where('code',$supplierNo)
  784. ->findOrEmpty();
  785. $data = [
  786. "bidNo" => $bidNo,
  787. "infoNo" => $infoNo,
  788. "zxNo" => $zxinfo['zxNo'],
  789. "spuCode" => $spucode,
  790. "good_name" => $pname,
  791. "brand_id" => $brandid,
  792. "cat_id" => $cat_id,
  793. "specinfo" => json_encode($specinfo),
  794. "unit_id" => $unit_id,
  795. "cost_desc" => $cost_desc,
  796. "work_day" => $work_day,
  797. "delivery_day" => $delivery_day,
  798. "good_img" => is_array($good_img) ? implode(',', $good_img) : $good_img,
  799. "expire_day" => $expire_day,
  800. "origin_place" => $origin_place,
  801. "supplierNo" => $supplierNo,
  802. "pay_way" => $pay_way,
  803. "tax" => $tax,
  804. "send_way" => $send_way,
  805. "metal_id" => $metal_id,
  806. "is_gold_price" => $is_gold_price,
  807. "config" => $config,
  808. "other_config" => $other_config,
  809. "weight" => $weight,
  810. "good_weight" => $good_weight,
  811. "gold_price" => isset($gold["price"]) ? $gold["price"] : 0,
  812. "is_diff" => $is_diff,
  813. "demo_fee" => $demo_fee,
  814. "delivery_fee" => $delivery_fee,
  815. "open_fee" => $open_fee,
  816. "pakge_fee" => $pakge_fee,
  817. "nake_fee" => $nake_fee,
  818. "mark_fee" => $mark_fee,
  819. "cert_fee" => $cert_fee,
  820. "cost_fee" => $cost_fee,
  821. "total_fee" => $total_fee,
  822. "supply_area" => $supply_area,
  823. "remark" => $remark,
  824. "sale_price" => $saleprice,
  825. "sale_cost_fee" => $sale_cost_fee,
  826. "origin_cost_fee" => $sale_cost_fee,
  827. "origin_price" => $saleprice,
  828. "createrid" => $createrid,
  829. "creater" => $creater,
  830. "status" => $zxinfo['status'] == 1 ? 1 : 2,
  831. "is_del" => 0,
  832. "addtime" => date("Y-m-d H:i:s"),
  833. "updatetime" => date("Y-m-d H:i:s"),
  834. 'delivery_place' => $delivery_place,//发货地
  835. 'cgder' => $supplier['person'] ?? '',
  836. 'cgderid' => $supplier['personid'] ?? 0,
  837. ];
  838. Db::startTrans();
  839. try {
  840. $insert = Db::name("consult_bids")->insert($data);
  841. if ($insert) {
  842. if ($zx['is_project'] == 1 && $zx['projectNo'] != "" && $zxinfo['pgNo'] != "") {
  843. $projectinfo = Db::name("project_info")->where(["pgNo" => $zxinfo["pgNo"], "projectNo" => $zx['projectNo'], "is_del" => 0])->find();
  844. if ($projectinfo == false) {
  845. Db::rollback();
  846. return json_show(1006, "未找到项目信息");
  847. }
  848. $temp = [];
  849. $temp['spuCode'] = $spucode;
  850. $temp['skuCode'] = "";
  851. $temp['pgNo'] = $zxinfo['pgNo'];
  852. $temp['projectNo'] = $zx['projectNo'];
  853. $temp['good_name'] = $pname;
  854. $temp['good_type'] = $projectinfo['good_type'];
  855. $temp['data_source'] = 2;
  856. $temp['cat_id'] = $cat_id;
  857. $temp['budget_price'] = $projectinfo['budget_price'];
  858. $temp['sale_price'] = $saleprice;
  859. $temp['origin_price'] = $total_fee;
  860. $temp['num'] = $zxinfo['num'];
  861. $temp['status'] = 0;
  862. $temp['is_del'] = 0;
  863. $temp['creater'] = $creater;
  864. $temp['createrid'] = $createrid;
  865. $temp['addtime'] = date("Y-m-d H:i:s");
  866. $temp['updatetime'] = date("Y-m-d H:i:s");
  867. $nu = Db::name("project_feedback")->insert($temp);
  868. if ($nu == false) {
  869. Db::rollback();
  870. return json_show(1006, "项目反馈失败");
  871. } else {
  872. $old_projectinfo_status = $projectinfo['status'];
  873. $projectinfo['status'] = 2;
  874. $projectinfo['updatetime'] = date("Y-m-d H:i:s");
  875. $up = Db::name("project_info")->save($projectinfo);
  876. if ($up) {
  877. //修改状态,添加待办,只记录动作
  878. ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
  879. "order_code" => $projectinfo['pgNo'],//编码
  880. "status" => $old_projectinfo_status,//这里的status是之前的值
  881. "action_remark" => '',//备注
  882. "action_type" => "status"//新建create,编辑edit,更改状态status
  883. ], "PRI", 2, $projectinfo);
  884. $count = Db::name("project_info")->where(["projectNo" => $projectinfo['projectNo'], "status" => 1])->count();
  885. if ($count == 0) {
  886. $projetc = Db::name("project")->where(["projectNo" => $projectinfo['projectNo'], "status" => 1])->find();
  887. if ($projetc != false) {
  888. $proc = Db::name("project")->where(["projectNo" => $projectinfo['projectNo'], "status" => 1])->save
  889. (["status" => 2, "updatetime" => date("Y-m-d H:i:s")]);
  890. if ($proc == false) {
  891. Db::rollback();
  892. return json_show(1006, "项目反馈失败");
  893. } else {
  894. //修改状态,添加待办
  895. ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
  896. "order_code" => $projetc['projectNo'],//项目编码
  897. "status" => 1,//这里的status是之前的值
  898. "action_remark" => '',//备注
  899. "action_type" => "status"//新建create,编辑edit,更改状态status
  900. ], "PRO", 2, $projetc);
  901. ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
  902. "order_type" => 'PRO',
  903. "order_code" => $projetc['projectNo'],
  904. "order_id" => $projetc['id'],
  905. "order_status" => 2,
  906. "before_status" => 1,
  907. 'holder_id'=>$projetc['createrid'],
  908. 'person_id' => Db::name('supplier')->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])->value('personid'),
  909. ]);
  910. }
  911. }
  912. }
  913. }
  914. }
  915. }
  916. Db::commit();
  917. return json_show(0, "反馈成功", ["bidNo" => $bidNo]);
  918. } else {
  919. Db::rollback();
  920. return json_show(1006, "反馈失败");
  921. }
  922. } catch (\Exception $e) {
  923. Db::rollback();
  924. return json_show(1006, $e->getMessage());
  925. }
  926. }
  927. //反馈商品编辑
  928. public function feededit()
  929. {
  930. $this->post = $this->request->filter('trim')->post();
  931. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] != "" ? trim($this->post['bidNo']) : "";
  932. if ($bidNo == "") {
  933. return json_show(1002, "参数bidNo不能为空");
  934. }
  935. $bidinfo = Db::name("consult_bids")->where(["bidNo" => $bidNo, "is_del" => 0])->find();
  936. if ($bidinfo == false) {
  937. return json_show(1003, "未找到信息数据");
  938. }
  939. if ($bidinfo['status'] >= 5) {
  940. return json_show(1004, "咨询单已确认无法修改");
  941. }
  942. $zxinfo = Db::name("consult_info")->where(["infoNo" => $bidinfo['infoNo'], "is_del" => 0])->find();
  943. if ($zxinfo == false) {
  944. return json_show(1003, "未找到信息数据");
  945. }
  946. $zx = Db::name("consult_order")->where(["zxNo" => $zxinfo['zxNo'], "is_del" => 0])->find();
  947. if ($zx == false) {
  948. return json_show(1003, "未找咨询信息数据");
  949. }
  950. $pname = isset($this->post['pname']) && $this->post['pname'] != "" ? trim($this->post['pname']) : "";
  951. if ($pname == "") {
  952. return json_show(1002, "参数pname不能为空");
  953. }
  954. $brandid = isset($this->post['brandid']) && $this->post['brandid'] != "" ? intval($this->post['brandid']) : "";
  955. // if($brandid==""){
  956. // return json_show(1002,"参数brandid不能为空");
  957. // }
  958. $cat_id = isset($this->post['cat_id']) && $this->post['cat_id'] != "" ? trim($this->post['cat_id']) : "";
  959. if ($cat_id == "") {
  960. return json_show(1002, "参数cat_id不能为空");
  961. }
  962. $specin = isset($this->post['specinfo']) && !empty($this->post['specinfo']) ? $this->post['specinfo'] : "";
  963. if ($specin == "") {
  964. return json_show(1003, "参数specinfo不能为空");
  965. }
  966. $specinfo = [];
  967. foreach ($specin as $v) {
  968. $spec = Db::name("specs")->where(["id" => $v['specid']])->find();
  969. $spec_value = Db::name("spec_value")->where(["id" => $v['spec_value_id']])->find();
  970. $v['spec_name'] = isset($spec['spec_name']) ? $spec['spec_name'] : "";
  971. $v['spec_value_name'] = isset($spec_value['spec_value']) ? $spec_value['spec_value'] : "";
  972. $specinfo[] = $v;
  973. }
  974. $unit_id = isset($this->post['unit_id']) && $this->post['unit_id'] != "" ? intval($this->post['unit_id']) : "";
  975. $cost_desc = isset($this->post['cost_desc']) && $this->post['cost_desc'] != "" ? trim($this->post['cost_desc']) : "";
  976. $work_day = isset($this->post['work_day']) && $this->post['work_day'] != "" ? intval($this->post['work_day']) : "";
  977. $delivery_day = isset($this->post['delivery_day']) && $this->post['delivery_day'] != "" ? intval($this->post['delivery_day']) : "";
  978. $good_img = isset($this->post['good_img']) && $this->post['good_img'] != "" ? $this->post['good_img'] : [];
  979. $expire_day = isset($this->post['expire_day']) && $this->post['expire_day'] != "" ? intval($this->post['expire_day']) : "";
  980. $origin_place = isset($this->post['origin_place']) && $this->post['origin_place'] != "" ? trim($this->post['origin_place']) : "";
  981. $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo'] != "" ? trim($this->post['supplierNo']) : "";
  982. $pay_way = isset($this->post['pay_way']) && $this->post['pay_way'] != "" ? intval($this->post['pay_way']) : "";
  983. $tax = isset($this->post['tax']) && $this->post['tax'] != "" ? trim($this->post['tax']) : "";
  984. $send_way = isset($this->post['send_way']) && $this->post['send_way'] != "" ? intval($this->post['send_way']) : "0";
  985. $metal_id = isset($this->post['metal_id']) && $this->post['metal_id'] != "" ? intval($this->post['metal_id']) : "0";
  986. $is_gold_price = isset($this->post['is_gold_price']) && $this->post['is_gold_price'] != "" ? intval($this->post['is_gold_price']) : "0";
  987. $config = isset($this->post['config']) && $this->post['config'] != "" ? $this->post['config'] : "";
  988. $other_config = isset($this->post['other_config']) && $this->post['other_config'] != "" ? $this->post['other_config'] : "";
  989. $weight = isset($this->post['weight']) && $this->post['weight'] != "" ? floatval($this->post['weight']) : "0";
  990. $noble_weight = isset($this->post['noble_weight']) && $this->post['noble_weight'] != "" ? floatval($this->post['noble_weight']) : "0";
  991. $demo_fee = isset($this->post['demo_fee']) && $this->post['demo_fee'] != "" ? floatval($this->post['demo_fee']) : "0";
  992. $delivery_fee = isset($this->post['delivery_fee']) && $this->post['delivery_fee'] != "" ? floatval($this->post['delivery_fee']) : "0";
  993. $open_fee = isset($this->post['open_fee']) && $this->post['open_fee'] != "" ? floatval($this->post['open_fee']) : "0";
  994. $pakge_fee = isset($this->post['pakge_fee']) && $this->post['pakge_fee'] != "" ? floatval($this->post['pakge_fee']) : "0";
  995. $nake_fee = isset($this->post['nake_fee']) && $this->post['nake_fee'] !== "" ? floatval($this->post['nake_fee']) : 0;
  996. $mark_fee = isset($this->post['mark_fee']) && $this->post['mark_fee'] != "" ? floatval($this->post['mark_fee']) : "0";
  997. $cert_fee = isset($this->post['cert_fee']) && $this->post['cert_fee'] != "" ? floatval($this->post['cert_fee']) : "0";
  998. $cost_fee = isset($this->post['cost_fee']) && $this->post['cost_fee'] != "" ? floatval($this->post['cost_fee']) : "0";
  999. $is_diff = isset($this->post['is_diff']) && $this->post['is_diff'] !== "" ? intval($this->post['is_diff']) : "";
  1000. $supply_area = isset($this->post['supply_area']) && $this->post['supply_area'] !== "" ? intval($this->post['supply_area']) : "";
  1001. $remark = isset($this->post['remark']) && $this->post['remark'] != "" ? trim($this->post['remark']) : "";
  1002. $delivery_place = isset($this->post['delivery_place']) && $this->post['delivery_place'] != '' ? trim($this->post['delivery_place']) : "";
  1003. if ($delivery_place == '') {
  1004. return json_show(1002, "参数delivery_place不能为空");
  1005. }
  1006. $catinfo = Db::name("cat")->where(["id" => $cat_id])->find();
  1007. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate'] / 100 : 0;
  1008. $sale_cost_fee = $bidinfo['sale_cost_fee'];
  1009. $cat_top_list = made($cat_id);
  1010. $cat_top_id = isset($cat_top_list[0]['id']) ? $cat_top_list[0]['id'] : 0;
  1011. if ($is_gold_price == 1 && $cat_top_id == 6) {
  1012. $gold = Db::name("gold_price1")->where(["type" => $metal_id, "is_del" => 0, "status" => 1])->order("addtime desc")->find();
  1013. //$total_fee(成本合计初始价格) =打样费/购买数量 + 开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价0+运费;
  1014. $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;
  1015. // $saleprice = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee/(1-$budget)* $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  1016. //$saleprice(最终售价) = (开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价)/(1-成本售价/100);
  1017. $saleprice = $total_fee / (1 - $budget);
  1018. //销售工艺费=((开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价)/(1-成本售价/100)-(打样费/购买数量 + 开模费/购买数量 +包装费+加标费+证书费+产品裸价0+运费) )/商品重量-最新金价
  1019. $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"];
  1020. } else {
  1021. $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);
  1022. $total_fee = $demo_fee / $zxinfo['num'] + $delivery_fee + $open_fee / $zxinfo['num'] + $cost_fee * $noble_weight + $pakge_fee + $mark_fee + $cert_fee + $nake_fee;
  1023. }
  1024. Db::startTrans();
  1025. try {
  1026. $createrid = $this->request->user['uid'];
  1027. $creater = $this->request->user['nickname'];
  1028. $data = [
  1029. "good_name" => $pname,
  1030. "brand_id" => $brandid,
  1031. "cat_id" => $cat_id,
  1032. "specinfo" => json_encode($specinfo),
  1033. // "material"=>$material,
  1034. "unit_id" => $unit_id,
  1035. "cost_desc" => $cost_desc,
  1036. "work_day" => $work_day,
  1037. "delivery_day" => $delivery_day,
  1038. "good_img" => is_array($good_img) ? implode(',', $good_img) : $good_img,
  1039. "expire_day" => $expire_day,
  1040. "origin_place" => $origin_place,
  1041. "supplierNo" => $supplierNo,
  1042. "pay_way" => $pay_way,
  1043. "tax" => $tax,
  1044. "send_way" => $send_way,
  1045. "metal_id" => $metal_id,
  1046. "is_gold_price" => $is_gold_price,
  1047. "config" => $config,
  1048. "other_config" => $other_config,
  1049. "weight" => $weight,
  1050. "good_weight" => $noble_weight,
  1051. "is_diff" => $is_diff,
  1052. "demo_fee" => $demo_fee,
  1053. "gold_price" => isset($gold["price"]) ? $gold["price"] : 0,
  1054. "delivery_fee" => $delivery_fee,
  1055. "open_fee" => $open_fee,
  1056. "pakge_fee" => $pakge_fee,
  1057. "nake_fee" => $nake_fee,
  1058. "mark_fee" => $mark_fee,
  1059. "cert_fee" => $cert_fee,
  1060. "cost_fee" => $cost_fee,
  1061. "sale_cost_fee" => $sale_cost_fee,
  1062. "origin_cost_fee" => $sale_cost_fee,
  1063. "total_fee" => $total_fee,
  1064. "sale_price" => $saleprice,
  1065. "origin_price" => $saleprice,
  1066. "supply_area" => $supply_area,
  1067. "remark" => $remark,
  1068. "status" => 0,
  1069. "updatetime" => date("Y-m-d H:i:s"),
  1070. 'delivery_place' => $delivery_place
  1071. ];
  1072. $insert = Db::name("consult_bids")->where($bidinfo)->save($data);
  1073. if ($insert) {
  1074. if ($zxinfo['bargain_status'] == 1) {
  1075. $zxinfo['bargain_status'] = 0;
  1076. $infoip = Db::name("consult_info")->save($zxinfo);
  1077. if ($infoip == false) {
  1078. Db::rollback();
  1079. return json_show(1006, "咨询信息状态更新失败");
  1080. }
  1081. }
  1082. if ($zx['is_project'] == 1 && $zx['projectNo'] != "" && $zxinfo['pgNo'] != "") {
  1083. $projectinfo = Db::name("project_info")->where(["pgNo" => $zxinfo["pgNo"], "projectNo" => $zx['projectNo'], "is_del" => 0])->find();
  1084. if ($projectinfo == false) {
  1085. Db::rollback();
  1086. return json_show(1006, "未找到项目信息");
  1087. }
  1088. $feed = Db::name("project_feedback")->where(["pgNo" => $zxinfo["pgNo"], "projectNo" => $zx['projectNo'], "spuCode" => $bidinfo['spuCode'], "is_del" => 0])->find();
  1089. if ($feed != false) {
  1090. $feed['good_name'] = $pname;
  1091. $feed['good_type'] = $projectinfo['good_type'];
  1092. $feed['cat_id'] = $cat_id;
  1093. $feed['sale_price'] = $saleprice;
  1094. $feed['origin_price'] = $total_fee;
  1095. $feed['updatetime'] = date("Y-m-d H:i:s");
  1096. $temp['updatetime'] = date("Y-m-d H:i:s");
  1097. $nu = Db::name("project_feedback")->save($feed);
  1098. if ($nu == false) {
  1099. Db::rollback();
  1100. return json_show(1006, "项目反馈失败");
  1101. } else {
  1102. $old_projectinfo_status = $projectinfo['status'];
  1103. $projectinfo['status'] = 2;
  1104. $projectinfo['updatetime'] = date("Y-m-d H:i:s");
  1105. $up = Db::name("project_info")->save($projectinfo);
  1106. if ($up) {
  1107. //修改状态,添加待办,只记录动作
  1108. ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
  1109. "order_code" => $projectinfo['pgNo'],//编码
  1110. "status" => $old_projectinfo_status,//这里的status是之前的值
  1111. "action_remark" => '',//备注
  1112. "action_type" => "status"//新建create,编辑edit,更改状态status
  1113. ], "PRI", 2, $projectinfo
  1114. );
  1115. $count = Db::name("project_info")->where(["projectNo" => $projectinfo['projectNo'], "status" => 1])->count();
  1116. if ($count == 0) {
  1117. //先查询是否存在status==1的项目,有的话再更新,否则跳过
  1118. $project_id = Db::name("project")->where(["projectNo" => $projectinfo['projectNo'], "status" => 1])->field('id,createrid')->findOrEmpty();
  1119. if ($project_id) {
  1120. $proc = Db::name("project")->where(["id" => $project_id['id']])->update(["status" => 2, "updatetime" => date("Y-m-d H:i:s")]);
  1121. if ($proc == false) {
  1122. Db::rollback();
  1123. return json_show(1006, "项目反馈失败");
  1124. } else {
  1125. //修改状态,添加待办
  1126. ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
  1127. "order_code" => $projectinfo['projectNo'],//项目编码
  1128. "status" => 1,//这里的status是之前的值
  1129. "action_remark" => '',//备注
  1130. "action_type" => "status"//新建create,编辑edit,更改状态status
  1131. ], "PRO", 2, $this->post);
  1132. ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
  1133. "order_type" => 'PRO',
  1134. "order_code" => $projectinfo['projectNo'],
  1135. "order_id" => $project_id['id'],
  1136. "order_status" => 2,
  1137. "before_status" => 1,
  1138. 'holder_id'=>$project_id['createrid'],
  1139. 'person_id' => Db::name('supplier')->where(['code' => $this->request->user['supplierNo'], 'is_del' => 0])->value('personid'),
  1140. ]
  1141. );
  1142. }
  1143. }
  1144. }
  1145. }
  1146. }
  1147. }
  1148. }
  1149. Db::commit();
  1150. return json_show(0, "编辑成功");
  1151. } else {
  1152. Db::rollback();
  1153. return json_show(1004, "编辑失败");
  1154. }
  1155. } catch (\Exception $e) {
  1156. Db::rollback();
  1157. return json_show(1004, $e->getMessage());
  1158. }
  1159. }
  1160. }