Consult.php 87 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741
  1. <?php
  2. namespace app\admin\controller;
  3. use think\App;
  4. use think\facade\Db;
  5. use think\facade\Validate;
  6. class Consult extends Base
  7. {
  8. public $noble=[];
  9. public function __construct(App $app)
  10. {
  11. parent::__construct($app);
  12. $this->noble =\think\facade\Config::get("noble");
  13. }
  14. public function conlist(){
  15. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  16. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  17. $where=[['a.is_del',"=",0],['b.is_del',"=",0]];
  18. $infoNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  19. if ($infoNo !== "") {
  20. $where[] = ['a.infoNo','=',$infoNo];
  21. }
  22. $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
  23. if ($salesman !== "") {
  24. //$where["salesman"] =Db::Raw("like '%$salesman%'");
  25. $where[]= ["b.salesman",'like',"%$salesman%"];
  26. }
  27. $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : "";
  28. if ($cpName !== "") {
  29. //$where["cpName"]= Db::Raw("like '%$cpName%'");
  30. $where[]= ["a.good_Name",'like',"%$cpName%"];
  31. }
  32. $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
  33. if ($khNo !== "") {
  34. // $where['khNo'] = $khNo;
  35. $where[]= ["b.khNo",'like',"%$khNo%"];
  36. }
  37. $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !== "" ? trim($this->post['companyNo']) : "";
  38. if ($companyNo !== "") {
  39. // $where['khNo'] = $khNo;
  40. $where[]= ["b.companyNo",'like',"%$companyNo%"];
  41. }
  42. $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
  43. if ($start !="") {
  44. //$where = ["zxtime"=>Db::raw(">= '{$start}'")];
  45. $where[]= ["a.addtime",'>=',$start];
  46. }
  47. $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
  48. if($end !=""){
  49. $where[]= ["a.addtime",'<=',$end];
  50. }
  51. $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
  52. if ($status !== "") {
  53. $where[]= ["a.status",'=',$status];
  54. }
  55. $count = Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)
  56. ->count();
  57. $total = ceil($count / $size);
  58. $page = $page >= $total ? $total : $page;
  59. $list =Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)->page($page,$size)
  60. ->field("a.*,b.createrid,b.creater,b.is_project,b.projectNo,b.khNo,b.endtime,b.platform_code,b.saleid,b.salesman,b.depart")->order("a.id desc")->select();
  61. $data=[];
  62. foreach ($list as $value){
  63. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  64. $value['specinfo']=isset($value['specinfo'])&&$value['specinfo']!=""? json_decode($value['specinfo'],
  65. true):[];
  66. $brand = Db::name("brand")->where(['id'=>$value['brand_id']])->find();
  67. $value['brand_name']= isset($brand['brand_name']) && $brand['brand_name']!='' ? $brand['brand_name']:"";
  68. $value['khname']="";
  69. if($value['khNo']!==""){
  70. $kh=Db::name("customer_info")->where(['companyNo'=>$value['khNo']])->find();
  71. $value['khname']= isset($kh['companyName'])?$kh['companyName']:"";
  72. }
  73. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  74. $data[]=$value;
  75. }
  76. return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
  77. }
  78. public function info(){
  79. $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) : "";
  80. if($id==""){
  81. return error_show(1002,"咨询单编号不能为空");
  82. }
  83. $fo = Db::name('consult')->where(['id'=>$id,'is_del'=>0])->find();
  84. $in= isset($fo['cat_id']) && $fo['cat_id'] !=0 ? made($fo['cat_id']):[];
  85. $fo['can']=$in;
  86. if(empty($fo)){
  87. return error_show(1002,"未找到咨询单编号");
  88. }else{
  89. return app_show(0,"获取成功",$fo);
  90. }
  91. }
  92. public function del(){
  93. $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) : "";
  94. $de = Db::name('consult')->where(['id'=>$id,'is_del'=>0])->find();
  95. if($de==false){
  96. return error_show(1002,'咨询单信息未找到');
  97. }
  98. $dell= Db::name('consult')->update(['id'=>$id,'is_del'=>1,'updatetime'=>date("Y-m-d H:i:s")]);
  99. if($dell){
  100. return error_show(0,"删除成功");
  101. }else
  102. return error_show(1002,"删除失败");
  103. }
  104. public function create(){
  105. $is_project= isset($this->post['is_project']) && $this->post['is_project'] !=="" ? intval($this->post['is_project']) : "";
  106. if($is_project===""){
  107. return error_show(1002,"参数is_project不能为空");
  108. }
  109. if($is_project==1){
  110. $projectNo= isset($this->post['projectNo']) && $this->post['projectNo'] !=="" ? trim($this->post['projectNo']) : "";
  111. if($projectNo===""){
  112. return error_show(1002,"参数projectNo不能为空");
  113. }
  114. }
  115. $khNo = isset($this->post['khNo']) && $this->post['khNo'] !=="" ? trim($this->post['khNo']) : "";
  116. if($khNo===""){
  117. return error_show(1002,"参数khNo不能为空");
  118. }
  119. $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !=="" ? trim($this->post['companyNo']) : "";
  120. if($companyNo===""){
  121. return error_show(1002,"参数companyNo不能为空");
  122. }
  123. $endtime = isset($this->post['endtime']) && $this->post['endtime'] !=="" ? $this->post['endtime'] : "";
  124. if($endtime===""){
  125. return error_show(1002,"参数endtime不能为空");
  126. }
  127. // $saleid = isset($this->post['saleid']) && $this->post['saleid'] !=="" ? intval($this->post['saleid']) : "";
  128. // if($saleid===""){
  129. // return error_show(1002,"参数saleid不能为空");
  130. // }
  131. // $depart = isset($this->post['depart']) && $this->post['depart'] !=="" ? intval($this->post['depart']) : "";
  132. // if($depart===""){
  133. // return error_show(1002,"参数depart不能为空");
  134. // }
  135. $platform_code = isset($this->post['platform_code']) && $this->post['platform_code'] !=="" ? trim($this->post['platform_code']) :
  136. "";
  137. if($platform_code===""){
  138. return error_show(1002,"参数platform_code不能为空");
  139. }
  140. $ladder = isset($this->post['ladder'])&&!empty($this->post['ladder']) ? $this->post['ladder']:"";
  141. if($ladder==""){
  142. return error_show(1005,"参数ladder不能为空");
  143. }
  144. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  145. if($token==''){
  146. return error_show(105,"参数token不能为空");
  147. }
  148. $user =GetUserInfo($token);
  149. if(empty($user)||$user['code']!=0){
  150. return error_show(102,"用户数据不存在");
  151. }
  152. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  153. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  154. $depart= Db::name("depart_user")->where(["uid"=>$createrid,"status"=>1,"is_del"=>0])->find();
  155. $zxNo=makeNo("ZX");
  156. $data=[
  157. "zxNo"=>$zxNo,
  158. "createrid"=>$createrid,
  159. "creater"=>$creater,
  160. "is_project"=>$is_project,
  161. "projectNo"=>isset($projectNo) ? $projectNo:"",
  162. "khNo"=>$khNo,
  163. "companyNo"=>$companyNo,
  164. "endtime"=>$endtime,
  165. "salesman"=>$creater,
  166. "platform_code"=>$platform_code,
  167. "saleid"=>$createrid,
  168. "depart"=>isset($depart['itemid'])?$depart['itemid']:0,
  169. "status"=>0,
  170. "is_del"=>0,
  171. "addtime"=>date("Y-m-d H:i:s"),
  172. "updatetime"=>date("Y-m-d H:i:s"),
  173. ];
  174. $zx = Db::name("consult_order")->insert($data);
  175. if($zx){
  176. foreach ($ladder as $value){
  177. $infoNo=makeNo("INF");
  178. $specinfo=[];
  179. if(isset($value['specinfo']) &&!empty($value['specinfo'])){
  180. foreach ($value["specinfo"] as $v){
  181. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  182. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  183. $v['spec_name']=isset($spec['spec_name'])? $spec['spec_name']:"";
  184. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"" ;
  185. $specinfo[]=$v;
  186. }
  187. }
  188. $info=[
  189. "infoNo"=>$infoNo,
  190. "zxNo"=>$zxNo,
  191. "spuCode"=>"",
  192. "good_name"=>$value['good_name'],
  193. "good_img"=>$value['good_img'],
  194. "cat_id"=>$value['cat_id'],
  195. "unit"=>$value['unit'],
  196. "brand_id"=>$value['brand_id'],
  197. "arrival_time"=>$value['arrival_time'],
  198. "specinfo"=>empty($specinfo)?"" : json_encode($specinfo),
  199. "cost_desc"=>$value['cost_desc'],
  200. "is_addrs"=>$value['is_addrs'],
  201. "is_custom"=>$value['is_custom'],
  202. "metal_id"=>$value['metal_id'],
  203. "config"=>isset($value['config'])?$value['config']:"",
  204. "other_config"=>isset($value['other_config'])?$value['other_config']:"",
  205. "specs_weight"=>isset($value['specs_weight'])?$value['specs_weight']:"0",
  206. "gold_price"=>isset($value['gold_price'])?$value['gold_price']:"0",
  207. "is_gold_price"=>isset($value['is_gold_price'])?$value['is_gold_price']:"0",
  208. "total_weight"=>isset($value['total_weight'])?$value['total_weight']:"0",
  209. "budget_price"=>$value['budget_price'],
  210. "num"=>$value['num'],
  211. "pgNo"=>isset($value['pgNo'])&&$value['pgNo']!==""?trim($value['pgNo']):"",
  212. "use_desc"=>$value['use_desc'],
  213. "remark"=>$value['remark'],
  214. "status"=>1,
  215. "is_del"=>0,
  216. "addtime"=>date("Y-m-d H:i:s"),
  217. "updatetime"=>date("Y-m-d H:i:s")
  218. ];
  219. $up = Db::name("consult_info")->insert($info);
  220. if(!$up){
  221. Db::rollback();
  222. return error_show(1004,'添加失败');
  223. }
  224. }
  225. return app_show(0,"新建成功",["zxNo"=>$zxNo]);
  226. }else{
  227. return error_show(1004,"新建失败");
  228. }
  229. }
  230. // public function zxadd(){
  231. // $good_name = isset($this->post['good_name'])&&$this->post['good_name']!==""?trim($this->post['good_name']):"";
  232. // if($good_name===""){
  233. // return error_show(1004,"参数good_name不能为空");
  234. // }
  235. // $zxNo = isset($this->post['zxNo'])&&$this->post['zxNo']!==""?trim($this->post['zxNo']):"";
  236. // if($zxNo===""){
  237. // return error_show(1004,"参数zxNo不能为空");
  238. // }
  239. //
  240. // $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!==""?intval($this->post['cat_id']):"";
  241. // if($cat_id===""){
  242. // return error_show(1004,"参数cat_id不能为空");
  243. // }
  244. // $arrival_time = isset($this->post['arrival_time'])&&$this->post['arrival_time']!==""?$this->post['arrival_time']
  245. // :"";
  246. // if($arrival_time===""){
  247. // return error_show(1004,"参数arrival_time不能为空");
  248. // }
  249. // $good_img = isset($this->post['good_img'])&&$this->post['good_img']!==""?trim($this->post['good_img']):"";
  250. // if($good_img===""){
  251. // return error_show(1004,"参数good_img不能为空");
  252. // }
  253. // $is_custom = isset($this->post['is_custom'])&&$this->post['is_custom']!==""?intval($this->post['is_custom']):"";
  254. // if($is_custom===""){
  255. // return error_show(1004,"参数is_custom不能为空");
  256. // }
  257. // $unit = isset($this->post['unit'])&&$this->post['unit']!==""?trim($this->post['unit']):"";
  258. // if($unit===""){
  259. // return error_show(1004,"参数unit不能为空");
  260. // }
  261. // $brand_id = isset($this->post['brand_id'])&&$this->post['brand_id']!==""?intval($this->post['brand_id']):"";
  262. // if($brand_id===""){
  263. // return error_show(1004,"参数brand_id不能为空");
  264. // }
  265. // $material = isset($this->post['material'])&&$this->post['material']!==""?trim($this->post['material']):"";
  266. // if($material===""){
  267. // return error_show(1004,"参数material不能为空");
  268. // }
  269. // $color = isset($this->post['color'])&&$this->post['color']!==""?trim($this->post['color']):"";
  270. // if($color===""){
  271. // return error_show(1004,"参数color不能为空");
  272. // }
  273. // $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!==""?trim($this->post['cost_desc']):"";
  274. // if($cost_desc===""){
  275. // return error_show(1004,"参数cost_desc不能为空");
  276. // }
  277. // $model = isset($this->post['model'])&&$this->post['model']!==""?trim($this->post['model']):"";
  278. // if($model===""){
  279. // return error_show(1004,"参数model不能为空");
  280. // }
  281. //
  282. // $is_addrs = isset($this->post['is_addrs'])&&$this->post['is_addrs']!==""?intval($this->post['is_addrs']):"";
  283. // if($is_addrs===""){
  284. // return error_show(1004,"参数is_addrs不能为空");
  285. // }
  286. //
  287. // $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!==""?trim($this->post['metal_id']):"";
  288. // if($metal_id===""){
  289. // return error_show(1004,"参数metal_id不能为空");
  290. // }
  291. // if($metal_id==0){
  292. // $config = isset($this->post['config'])&&!empty($this->post['config'])?$this->post['config']:"";
  293. // if($config===""){
  294. // return error_show(1004,"参数config不能为空");
  295. // }
  296. // $other_config = isset($this->post['other_config'])&&$this->post['other_config']!==""?trim($this->post['other_config'])
  297. // :"";
  298. // if($other_config===""){
  299. // return error_show(1004,"参数other_config不能为空");
  300. // }
  301. // $specs_weight = isset($this->post['specs_weight'])&&$this->post['specs_weight']!==""?floatval($this->post['specs_weight']):"";
  302. // if($specs_weight===""){
  303. // return error_show(1004,"参数specs_weight不能为空");
  304. // }
  305. // $gold_price = isset($this->post['gold_price'])&&$this->post['gold_price']!==""?floatval($this->post['gold_price']):"";
  306. // if($gold_price===""){
  307. // return error_show(1004,"参数gold_price不能为空");
  308. // }
  309. //
  310. // }
  311. // $budget_price = isset($this->post['budget_price'])&&$this->post['budget_price']!==""?floatval($this->post['budget_price']):"";
  312. // if($budget_price===""){
  313. // return error_show(1004,"参数budget_price不能为空");
  314. // }
  315. // $num = isset($this->post['num'])&&$this->post['num']!==""?intval($this->post['num']):"";
  316. // if($num===""){
  317. // return error_show(1004,"参数num不能为空");
  318. // }
  319. // $use_desc = isset($this->post['use_desc'])&&$this->post['use_desc']!==""?trim($this->post['use_desc']):"";
  320. // if($use_desc===""){
  321. // return error_show(1004,"参数use_desc不能为空");
  322. // }
  323. // $remark = isset($this->post['remark'])&&$this->post['remark']!==""?trim($this->post['remark']):"";
  324. // if($remark===""){
  325. // return error_show(1004,"参数remark不能为空");
  326. // }
  327. //
  328. // Db::startTrans();
  329. // try{
  330. // $infoNo=makeNo("INF");
  331. // $info=[
  332. // "infoNo"=>$infoNo,
  333. // "zxNo"=>$zxNo,
  334. // "spuCode"=>"",
  335. // "good_name"=>$good_name,
  336. // "good_img"=>$good_img,
  337. // "cat_id"=>$cat_id,
  338. // "unit"=>$unit,
  339. // "brand_id"=>$brand_id,
  340. // "arrival_time"=>$arrival_time,
  341. // "model"=>$model,
  342. // "color"=>$color,
  343. // "material"=>$material,
  344. // "cost_desc"=>$cost_desc,
  345. // "is_addrs"=>$is_addrs,
  346. // "is_custom"=>$is_custom,
  347. // "metal_id"=>$metal_id,
  348. // "config"=>isset($config)?$config:"",
  349. // "other_config"=>isset($other_config)?$other_config:"",
  350. // "specs_weight"=>isset($specs_weight)?$specs_weight:0,
  351. // "gold_price"=>isset($gold_price)?$gold_price:0,
  352. // "budget_price"=>$budget_price,
  353. // "num"=>$num,
  354. // "use_desc"=>$use_desc,
  355. // "remark"=>$remark,
  356. // "status"=>0,
  357. // "is_del"=>0,
  358. // "addtime"=>date("Y-m-d H:i:s"),
  359. // "updatetime"=>date("Y-m-d H:i:s")
  360. // ];
  361. // $up = Db::name("consult_info")->insert($info);
  362. // if($up){
  363. // Db::commit();
  364. // return app_show(0,"添加成功",["infoNo"=>$infoNo]);
  365. // }else{
  366. // Db::rollback();
  367. // return error_show(1004,'添加失败');
  368. // }
  369. // }catch (\Exception $e){
  370. // Db::rollback();
  371. // return error_show(1004,$e->getMessage());
  372. // }
  373. // }
  374. public function zxinfo(){
  375. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  376. if($infoNo==""){
  377. return error_show(1004,"参数infoNo不能为空");
  378. }
  379. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  380. if($zxinfo==false){
  381. return error_show(1004,"未找到信息数据");
  382. }
  383. $zxorder = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
  384. if($zxorder==false){
  385. return error_show(1004,"未找到咨询信息数据");
  386. }
  387. $cat =Db::name("cat")->where(["id"=>$zxinfo['cat_id']])->find();
  388. $budget = isset($cat['order_rate']) ? $cat['order_rate']:0;
  389. $zxinfo['can']= isset($zxinfo['cat_id']) && $zxinfo['cat_id'] !=0 ? made($zxinfo['cat_id'],[]):[];
  390. $zxinfo['khname']="";
  391. $zxinfo['original_price']=sprintf("%.2f",$zxinfo['budget_price']* (1 -$budget/100));
  392. $zxinfo['khNo']="";
  393. $zxinfo['brand_id']=$zxinfo['brand_id']==0 ?"":$zxinfo['brand_id'];
  394. $zxinfo['brand']="";
  395. $zxinfo['companyNo']=isset($zxorder['companyNo'])?$zxorder['companyNo']:"";
  396. $zxinfo['projectNo']=isset($zxorder['projectNo'])?$zxorder['projectNo']:"";
  397. $zxinfo['is_project']=isset($zxorder['is_project'])?$zxorder['is_project']:"";
  398. $zxinfo['company']="";
  399. $zxinfo['endtime']=isset($zxorder['endtime'])?$zxorder['endtime']:"";
  400. $zxinfo['platform_code'] =isset($zxorder['platform_code'])?$zxorder['platform_code']:"";
  401. $zxinfo['salesman'] =isset($zxorder['salesman'])?$zxorder['salesman']:"";
  402. $zxinfo['saleid'] =isset($zxorder['saleid'])?$zxorder['saleid']:"";
  403. $zxinfo['depart'] =isset($zxorder['depart'])?$zxorder['depart']:"";
  404. $zxinfo['project_name']="";
  405. $zxinfo['budget_total']="";
  406. $zxinfo['departinfo']=[];
  407. $zxinfo['unit_name']="";
  408. $zxinfo['metal_name']=isset($zxinfo['metal_id'])&& $zxinfo['metal_id']!=0?$this->noble[$zxinfo['metal_id']]:"";
  409. $zxinfo['specinfo']=json_decode($zxinfo['specinfo'],true);
  410. if($zxorder['khNo']!==""){
  411. $kh=Db::name("customer_info")->where(['companyNo'=>$zxorder['khNo']])->find();
  412. $zxinfo['khname']= isset($kh['companyName'])?$kh['companyName']:"";
  413. $zxinfo['khNo']= $zxorder['khNo'];
  414. }
  415. if($zxinfo['unit']!==""){
  416. $unit=Db::name("unit")->where(['id'=>$zxinfo['unit']])->find();
  417. $zxinfo['unit_name']= isset($unit['unit'])?$unit['unit']:"";
  418. }
  419. if($zxinfo['brand_id']!==""){
  420. $unit=Db::name("brand")->where(['id'=>$zxinfo['brand_id']])->find();
  421. $zxinfo['brand']= isset($unit['brand_name'])?$unit['brand_name']:"";
  422. }
  423. if($zxorder['companyNo']!==""){
  424. $kh=Db::name("business")->where(['companyNo'=>$zxorder['companyNo']])->find();
  425. $zxinfo['company']= isset($kh['company'])?$kh['company']:"";
  426. }
  427. if($zxorder['is_project']==1 && $zxorder['projectNo']!==""){
  428. $project = Db::name("project")->where(["projectNo"=>$zxorder['projectNo'],"is_del"=>0])->find();
  429. $zxinfo['project_name']=isset($project['project_name'])?$project['project_name']:"";
  430. $zxinfo['budget_total']=isset($project['budget_total'])?$project['budget_total']:"";
  431. $zxinfo['project_use_desc']=isset($project['use_desc'])?$project['use_desc']:"";
  432. $projectinfo = Db::name("project_info")->where(["pgNo"=>$zxinfo['pgNo']])->find();
  433. $zxinfo['pgNo'] = isset($projectinfo['pgNo']) ? $projectinfo['pgNo']:"";
  434. }
  435. if($zxorder['depart']>0){
  436. $zxinfo['departinfo']=GetPart($zxorder['depart']);
  437. }
  438. if($zxorder['platform_code']>0){
  439. $palt=Db::name("platform")->where(["id"=>$zxorder['platform_code']])->find();
  440. $zxinfo['platform_name']=isset($palt['platform_name'])?$palt['platform_name']:"";
  441. }
  442. return app_show(0,"获取成功",$zxinfo);
  443. }
  444. public function zxedit(){
  445. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  446. if($infoNo==""){
  447. return error_show(1004,"参数infoNo不能为空");
  448. }
  449. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  450. if($zxinfo==false){
  451. return error_show(1004,"未找到信息数据");
  452. }
  453. $good_name= isset($this->post['good_name'])&&$this->post['good_name']!=""?trim($this->post['good_name']):"";
  454. if($good_name==""){
  455. return error_show(1003,"参数good_name不能为空");
  456. }
  457. $good_img= isset($this->post['good_img'])&&$this->post['good_img']!=""?trim($this->post['good_img']):"";
  458. if($good_img==""){
  459. return error_show(1003,"参数good_img不能为空");
  460. }
  461. $cat_id= isset($this->post['cat_id'])&&$this->post['cat_id']!=""?intval($this->post['cat_id']):"";
  462. if($cat_id==""){
  463. return error_show(1003,"参数cat_id不能为空");
  464. }
  465. $unit= isset($this->post['unit'])&&$this->post['unit']!=""?trim($this->post['unit']):"";
  466. if($unit==""){
  467. return error_show(1003,"参数unit不能为空");
  468. }
  469. $brand_id= isset($this->post['brand_id'])&&$this->post['brand_id']!==""?intval($this->post['brand_id']):"0";
  470. $arrival_time= isset($this->post['arrival_time'])&&$this->post['arrival_time']!=""?$this->post['arrival_time']:"";
  471. if($arrival_time==""){
  472. return error_show(1003,"参数arrival_time不能为空");
  473. }
  474. $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
  475. if($specin==""){
  476. return error_show(1003,"参数specinfo不能为空");
  477. }
  478. // $color= isset($this->post['color'])&&$this->post['color']!=""?trim($this->post['color']):"";
  479. // if($color==""){
  480. // return error_show(1003,"参数color不能为空");
  481. // }
  482. // $material= isset($this->post['material'])&&$this->post['material']!=""?trim($this->post['material']):"";
  483. // if($material==""){
  484. // return error_show(1003,"参数material不能为空");
  485. // }
  486. $cost_desc= isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""?trim($this->post['cost_desc']):"";
  487. if($cost_desc==""){
  488. return error_show(1003,"参数cost_desc不能为空");
  489. }
  490. $is_addrs= isset($this->post['is_addrs'])&&$this->post['is_addrs']!==""?intval($this->post['is_addrs']):"";
  491. if($is_addrs===""){
  492. return error_show(1003,"参数is_addrs不能为空");
  493. }
  494. $is_custom= isset($this->post['is_custom'])&&$this->post['is_custom']!==""?trim($this->post['is_custom']):"";
  495. if($is_custom===""){
  496. return error_show(1003,"参数is_custom不能为空");
  497. }
  498. $metal_id= isset($this->post['metal_id'])&&$this->post['metal_id']!==""?intval($this->post['metal_id']):"";
  499. if($metal_id===""){
  500. return error_show(1003,"参数metal_id不能为空");
  501. }
  502. $config = isset($this->post['config'])&& $this->post['config']!=""?trim($this->post['config']):"";
  503. $other_config = isset($this->post['other_config'])&& $this->post['other_config']!=""?trim($this->post['other_config']):"";
  504. $specs_weight = isset($this->post['specs_weight'])&& $this->post['specs_weight']!==""?floatval($this->post['specs_weight']):"";
  505. $gold_price = isset($this->post['gold_price'])&& $this->post['gold_price']!==""?floatval($this->post['gold_price']):"";
  506. $is_gold_price = isset($this->post['is_gold_price'])&& $this->post['is_gold_price']!==""?intval($this->post['is_gold_price']):"0";
  507. $budget_price = isset($this->post['budget_price'])&& $this->post['budget_price']!==""?floatval($this->post['budget_price']):"";
  508. $total_weight = isset($this->post['total_weight'])&& $this->post['total_weight']!==""?floatval($this->post['total_weight']):"";
  509. $num = isset($this->post['num'])&& $this->post['num']!==""?intval($this->post['num']):"";
  510. if($num===""){
  511. return error_show(1003,"参数num不能为空");
  512. }
  513. if($budget_price===""){
  514. return error_show(1003,"参数budget_price不能为空");
  515. }
  516. $pgNo = isset($this->post['pgNo'])&& $this->post['pgNo']!="" ? trim($this->post['pgNo']):"";
  517. $use_desc = isset($this->post['use_desc'])&& $this->post['use_desc']!="" ? trim($this->post['use_desc']):"";
  518. if($use_desc==""){
  519. return error_show(1003,"参数use_desc不能为空");
  520. }
  521. $remark = isset($this->post['remark'])&& $this->post['remark']!="" ? trim($this->post['remark']):"";
  522. if($remark==""){
  523. return error_show(1003,"参数remark不能为空");
  524. }
  525. if($metal_id!=0){
  526. if($config==""){
  527. return error_show(1003,"参数config不能为空");
  528. }
  529. if($other_config==""){
  530. return error_show(1003,"参数other_config不能为空");
  531. }
  532. if($specs_weight===""){
  533. return error_show(1003,"参数specs_weight不能为空");
  534. }
  535. if($gold_price===""){
  536. return error_show(1003,"参数gold_price不能为空");
  537. }
  538. }
  539. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  540. if($token==''){
  541. return error_show(102,"参数token不能为空");
  542. }
  543. $user =GetUserInfo($token);
  544. if(empty($user)||$user['code']!=0){
  545. return error_show(105,"用户数据不存在");
  546. }
  547. $specinfo=[];
  548. foreach ($specin as $v){
  549. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  550. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  551. $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
  552. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
  553. $specinfo[]=$v;
  554. }
  555. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  556. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  557. $bidlist = Db::name("consult_bids")->where(["infoNo"=>$zxinfo['infoNo'],"is_del"=>0])->select();
  558. try{
  559. $innew =makeNo("INF");
  560. $info=[
  561. "infoNo"=>$innew,
  562. "zxNo"=>$zxinfo['zxNo'],
  563. "spuCode"=>"",
  564. "good_name"=>$good_name,
  565. "good_img"=>$good_img,
  566. "cat_id"=>$cat_id,
  567. "unit"=>$unit,
  568. "brand_id"=>$brand_id,
  569. "arrival_time"=>$arrival_time,
  570. "specinfo"=>json_encode($specinfo),
  571. // "color"=>$color,
  572. // "material"=>$material,
  573. "cost_desc"=>$cost_desc,
  574. "is_addrs"=>$is_addrs,
  575. "is_custom"=>$is_custom,
  576. "metal_id"=>$metal_id,
  577. "config"=>$config,
  578. "other_config"=>$other_config,
  579. "specs_weight"=>$specs_weight===""?0:$specs_weight,
  580. "gold_price"=>$gold_price===""? 0 : $gold_price,
  581. "is_gold_price"=>$is_gold_price===""?0:$is_gold_price,
  582. "total_weight"=>$total_weight===""? $num*$specs_weight :$total_weight,
  583. "budget_price"=>$budget_price,
  584. "num"=>$num,
  585. "pgNo"=>$pgNo,
  586. "use_desc"=>$use_desc,
  587. "remark"=>$remark,
  588. "status"=>1,
  589. "is_del"=>0,
  590. "addtime"=>date("Y-m-d H:i:s"),
  591. "updatetime"=>date("Y-m-d H:i:s")
  592. ];
  593. $up = Db::name("consult_info")->insert($info);
  594. if($up){
  595. if (!empty($bidlist)){
  596. foreach ($bidlist as $value){
  597. unset($value['id']);
  598. $value['infoNo']=$innew;
  599. $value['bidNo']=makeNo("BD");
  600. $value['spuCode']=makeNo("SPU");
  601. $value['status'] =0;
  602. $value['updatetime'] =date("Y-m-d H:i:s");
  603. $in = Db::name("consult_bids")->insert($value);
  604. if($in==false){
  605. Db::rollback();
  606. return error_show(1004,"反馈商品新建失败");
  607. }
  608. }
  609. }
  610. $zxinfo["bargain_status"] =1;
  611. $zxinfo["bargain_code"] =$innew;
  612. $zxinfo["updatetime"] =date("Y-m-d H:i:s");
  613. $bar=Db::name("consult_info")->save($zxinfo);
  614. if($bar==false){
  615. Db::rollback();
  616. return error_show(1004,"反馈商品更新失败");
  617. }
  618. Db::commit();
  619. return app_show(0,"咨询新建成功",["infoNo"=>$innew]);
  620. }
  621. }catch (\Exception $e){
  622. Db::rollback();
  623. return error_show(1004,$e->getMessage());
  624. }
  625. }
  626. //** 发布竞标任务 */
  627. public function bargain(){
  628. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  629. if($infoNo==""){
  630. return error_show(1004,"参数infoNo不能为空");
  631. }
  632. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  633. if($zxinfo==false){
  634. return error_show(1004,"未找到信息数据");
  635. }
  636. $status =isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
  637. if($status===""){
  638. return error_show(1004,"参数status不能为空");
  639. }
  640. if($status==1&&$zxinfo['status']>1){
  641. $zxinfo['bargain_num']=+1;
  642. }
  643. $zxinfo['status']=$status;
  644. $zxinfo['updatetime']=date("Y-m-d H:i:s");
  645. $up = Db::name("consult_info")->save($zxinfo);
  646. if($up){
  647. return app_show(0,"状态更新成功");
  648. }else{
  649. return error_show(1003,"状态更新失败");
  650. }
  651. }
  652. public function feadback(){
  653. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  654. if($infoNo==""){
  655. return error_show(1002,"参数infoNo不能为空");
  656. }
  657. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  658. if($zxinfo==false){
  659. return error_show(1003,"未找到信息数据");
  660. }
  661. if($zxinfo['status']!=1){
  662. return error_show(1004,"任务未进行");
  663. }
  664. $zx = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
  665. if($zx==false){
  666. return error_show(1003,"未找咨询信息数据");
  667. }
  668. $pname = isset($this->post['pname'])&&$this->post['pname']!=""? trim($this->post['pname']):"";
  669. if($pname==""){
  670. return error_show(1002,"参数pname不能为空");
  671. }
  672. $brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):"";
  673. $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? trim($this->post['cat_id']):"";
  674. if($cat_id==""){
  675. return error_show(1002,"参数cat_id不能为空");
  676. }
  677. $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
  678. if($specin==""){
  679. return error_show(1003,"参数specinfo不能为空");
  680. }
  681. $specinfo=[];
  682. foreach ($specin as $v){
  683. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  684. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  685. $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
  686. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
  687. $specinfo[]=$v;
  688. }
  689. $unit_id = isset($this->post['unit_id'])&&$this->post['unit_id']!=""? intval($this->post['unit_id']):"";
  690. $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""? trim($this->post['cost_desc']):"";
  691. $work_day = isset($this->post['work_day'])&&$this->post['work_day']!=""? intval($this->post['work_day']):"";
  692. $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!=""? intval($this->post['delivery_day']):"";
  693. $good_img = isset($this->post['good_img'])&&$this->post['good_img']!=""? trim($this->post['good_img']):"";
  694. $expire_day = isset($this->post['expire_day'])&&$this->post['expire_day']!=""? intval($this->post['expire_day'])
  695. :"";
  696. $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!=""? trim($this->post['origin_place']):"";
  697. $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
  698. $pay_way = isset($this->post['pay_way'])&&$this->post['pay_way']!=""? intval($this->post['pay_way']):"";
  699. $tax = isset($this->post['tax'])&&$this->post['tax']!=""? trim($this->post['tax']):"";
  700. $send_way = isset($this->post['send_way'])&&$this->post['send_way']!=""? intval($this->post['send_way']):"";
  701. $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!=""? intval($this->post['metal_id']):"";
  702. $is_gold_price = isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!=""? intval($this->post['is_gold_price']):"";
  703. $config = isset($this->post['config'])&&$this->post['config']!=""? $this->post['config']:"";
  704. $other_config = isset($this->post['other_config'])&&$this->post['other_config']!=""? $this->post['other_config']:"";
  705. $weight = isset($this->post['weight'])&&$this->post['weight']!==""? floatval($this->post['weight']):"";
  706. $good_weight = isset($this->post['good_weight'])&&$this->post['good_weight']!==""? floatval($this->post['good_weight']):"";
  707. $demo_fee = isset($this->post['demo_fee'])&&$this->post['demo_fee']!==""? floatval($this->post['demo_fee']):"";
  708. $delivery_fee = isset($this->post['delivery_fee'])&&$this->post['delivery_fee']!==""? floatval($this->post['delivery_fee']):"";
  709. $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!==""? floatval($this->post['open_fee']):"";
  710. $pakge_fee = isset($this->post['pakge_fee'])&&$this->post['pakge_fee']!==""? floatval
  711. ($this->post['pakge_fee']):"";
  712. $nake_fee = isset($this->post['nake_fee'])&&$this->post['nake_fee']!==""? floatval($this->post['nake_fee']):"";
  713. $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!==""? floatval($this->post['mark_fee']):"";
  714. $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!==""? floatval($this->post['cert_fee']):"";
  715. $cost_fee = isset($this->post['cost_fee'])&&$this->post['cost_fee']!==""? floatval($this->post['cost_fee']):"";
  716. if($nake_fee==="" ||$nake_fee==0 ){
  717. return error_show(1004,"参数nake_fee不能为空或零");
  718. }
  719. $is_diff = isset($this->post['is_diff'])&&$this->post['is_diff']!==""? intval($this->post['is_diff']):"";
  720. $supply_area = isset($this->post['supply_area'])&&$this->post['supply_area']!==""? intval($this->post['supply_area']):"";
  721. $remark = isset($this->post['remark'])&&$this->post['remark']!=""? trim($this->post['remark']):"";
  722. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  723. if($token==''){
  724. return error_show(1002,"参数token不能为空");
  725. }
  726. $user =GetUserInfo($token);
  727. if(empty($user)||$user['code']!=0){
  728. return error_show(1005,"用户数据不存在");
  729. }
  730. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  731. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  732. $bidNo=makeNo("BD");
  733. $spucode=makeNo("SPU");
  734. $catinfo = Db::name("cat")->where(["id"=>$cat_id])->find();
  735. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:0;
  736. //部分参数的大小校验
  737. $vali = Validate::rule([
  738. 'expire_day|有效时长'=>'require|number|elt:2147483640',
  739. 'delivery_day|物流时长'=>'require|number|elt:2147483640',
  740. 'work_day|生产工期'=>'require|number|elt:2147483640',
  741. 'weight|总重量'=>'require|number|elt:2147483640',
  742. ]);
  743. $temp = [
  744. 'expire_day'=>$this->post['expire_day'],
  745. 'delivery_day'=>$this->post['delivery_day'],
  746. 'work_day'=>$this->post['work_day'],
  747. 'weight'=>$this->post['weight'],
  748. ];
  749. if(!$vali->check($temp)) return error_show(0,$vali->getError());
  750. if($is_gold_price==1){
  751. $gold = Db::name("gold_price1")->where(["type"=>$metal_id,"is_del"=>0,"status"=>1])->order("addtime desc")
  752. ->find();
  753. $total_fee = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee*
  754. $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  755. $saleprice = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee/(1-$budget)*
  756. $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  757. }else{
  758. $saleprice = $open_fee/$zxinfo['num'] +
  759. $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee/(1-$budget);
  760. $total_fee = $open_fee/$zxinfo['num'] +
  761. $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  762. }
  763. $data=[
  764. "bidNo"=>$bidNo,
  765. "infoNo"=>$infoNo,
  766. "zxNo"=>$zxinfo['zxNo'],
  767. "spuCode"=>$spucode,
  768. "good_name"=>$pname,
  769. "brand_id"=>$brandid,
  770. "cat_id"=>$cat_id,
  771. "specinfo"=>json_encode($specinfo),
  772. "unit_id"=>$unit_id,
  773. "cost_desc"=>$cost_desc,
  774. "work_day"=>$work_day,
  775. "delivery_day"=>$delivery_day,
  776. "good_img"=>$good_img,
  777. "expire_day"=>$expire_day,
  778. "origin_place"=>$origin_place,
  779. "supplierNo"=>$supplierNo,
  780. "pay_way"=>$pay_way,
  781. "tax"=>$tax,
  782. "send_way"=>$send_way,
  783. "metal_id"=>$metal_id,
  784. "is_gold_price"=>$is_gold_price,
  785. "config"=>$config,
  786. "other_config"=>$other_config,
  787. "weight"=>$weight,
  788. "good_weight"=>$good_weight,
  789. "is_diff"=>$is_diff,
  790. "demo_fee"=>$demo_fee,
  791. "delivery_fee"=>$delivery_fee,
  792. "open_fee"=>$open_fee,
  793. "pakge_fee"=>$pakge_fee,
  794. "nake_fee"=>$nake_fee,
  795. "mark_fee"=>$mark_fee,
  796. "cert_fee"=>$cert_fee,
  797. "cost_fee"=>$cost_fee,
  798. "total_fee"=>$total_fee,
  799. "supply_area"=>$supply_area,
  800. "remark"=>$remark,
  801. "sale_price"=>$saleprice,
  802. "origin_price"=>$saleprice,
  803. "createrid"=>$createrid,
  804. "creater"=>$creater,
  805. "status"=>$zxinfo['status']==1 ?1 :2,
  806. "is_del"=>0,
  807. "addtime"=>date("Y-m-d H:i:s"),
  808. "updatetime"=>date("Y-m-d H:i:s")
  809. ];
  810. Db::startTrans();
  811. try{
  812. $insert= Db::name("consult_bids")->insert($data);
  813. if($insert){
  814. // $data=[
  815. // "spuCode"=>$spucode,
  816. // "good_name"=>$pname,
  817. // "brand_id"=>$brandid,
  818. // "good_unit"=>$unit_id,
  819. // "good_type"=>0,
  820. // "moq"=>1,
  821. // "customized"=>$work_day,
  822. // "tax"=>$tax,
  823. // "supplierNo"=>$supplierNo,
  824. // "is_auth"=>0,
  825. // "craft_desc"=>$cost_desc,
  826. // "good_remark"=>$remark,
  827. // "good_img"=>$good_img,
  828. // "good_thumb_img"=>"",
  829. // "good_info_img"=>"",
  830. // "status"=>1,
  831. // "is_del"=>0,
  832. // "createrid"=>$createrid,
  833. // "creater"=>$creater,
  834. // "addtime"=>date("Y-m-d H:i:s"),
  835. // "updatetime"=>date("Y-m-d H:i:s")
  836. // ];
  837. // $good = Db::name("good_zixun")->insert($data);
  838. if($zx['is_project']==1 && $zx['projectNo']!="" && $zxinfo['pgNo']!=""){
  839. $projectinfo =Db::name("project_info")->where(["pgNo"=>$zxinfo["pgNo"],"projectNo"=>$zx['projectNo'],"is_del"=>0])->find();
  840. if($projectinfo==false){
  841. Db::rollback();
  842. return error_show(1006,"未找到项目信息");
  843. }
  844. $temp=[];
  845. $temp['spuCode']=$spucode;
  846. $temp['skuCode']="";
  847. $temp['pgNo']=$zxinfo['pgNo'];
  848. $temp['projectNo']=$zx['projectNo'];
  849. $temp['good_name']=$pname;
  850. $temp['good_type']=$projectinfo['good_type'];
  851. $temp['data_source']=2;
  852. $temp['cat_id']=$cat_id;
  853. $temp['budget_price']=$projectinfo['budget_price'];
  854. $temp['sale_price']=$saleprice;
  855. $temp['origin_price']=$total_fee;
  856. $temp['num']=$zxinfo['num'];
  857. $temp['status']=0;
  858. $temp['is_del']=0;
  859. $temp['creater']=$creater;
  860. $temp['createrid']=$createrid;
  861. $temp['addtime']=date("Y-m-d H:i:s");
  862. $temp['updatetime']=date("Y-m-d H:i:s");
  863. $nu = Db::name("project_feedback")->insert($temp);
  864. if($nu==false){
  865. Db::rollback();
  866. return error_show(1006,"项目反馈失败");
  867. }else{
  868. $projectinfo['status']=2;
  869. $projectinfo['updatetime']=date("Y-m-d H:i:s");
  870. $up = Db::name("project_info")->save($projectinfo);
  871. if($up){
  872. $count = Db::name("project_info")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])
  873. ->count();
  874. if($count==0){
  875. $proc =Db::name("project")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])->save
  876. (["status"=>2,"updatetime"=>date("Y-m-d H:i:s")]);
  877. if($proc==false){
  878. Db::rollback();
  879. return error_show(1006,"项目反馈失败");
  880. }
  881. }
  882. }
  883. }
  884. }
  885. Db::commit();
  886. return app_show(0,"反馈成功",["bidNo"=>$bidNo]);
  887. }else{
  888. Db::rollback();
  889. return error_show(1006,"反馈失败");
  890. }
  891. }catch (\Exception $e){
  892. Db::rollback();
  893. return error_show(1006,$e->getMessage());
  894. }
  895. }
  896. public function feadinfo(){
  897. $bidNo =isset($this->post['bidNo'])&& $this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  898. if($bidNo==""){
  899. return error_show(1004,"参数bidNo不能为空");
  900. }
  901. $info =Db::name("consult_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
  902. if($info==false){
  903. return error_show(1004,"未找到商品数据");
  904. }
  905. $unit =Db::name("unit")->where(["id"=>$info['unit_id']])->find();
  906. $info['unit'] = isset($unit['unit'])?$unit['unit']:'';
  907. $info['cat_info'] = made($info['cat_id'],[]);
  908. $supplier = Db::name("supplier")->where(["code"=>$info['supplierNo']])->find();
  909. $info['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  910. if($info['brand_id']!=0){
  911. $brand=Db::name("brand")->where(["id"=>$info['brand_id']])->find();
  912. $info["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  913. }else{
  914. $info["brand_name"]="";
  915. $info["brand_id"]="";
  916. }
  917. $catinfo = Db::name("cat")->where(["id"=>$info['cat_id']])->find();
  918. $bidinfo = Db::name("consult_info")->where(["infoNo"=>$info["infoNo"]])->find();
  919. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
  920. $god=[
  921. "metal_id"=>$info['metal_id'],
  922. "weight"=>$info["weight"],
  923. "demo_fee"=>$info["demo_fee"],
  924. "delivery_fee"=>$info["delivery_fee"],
  925. "open_fee"=>$info["open_fee"],
  926. "packing_fee"=>$info["pakge_fee"],
  927. "mark_fee"=>$info["mark_fee"],
  928. "nake_fee"=>$info["nake_fee"],
  929. "cert_fee"=>$info["cert_fee"],
  930. "cost_fee"=>$info["cost_fee"],
  931. "num"=>$bidinfo["num"],
  932. ];
  933. if($info['is_gold_price']==1){
  934. $price = GoldPrice($god, $budget/100);
  935. $info['sale_price'] =round($price,2);
  936. }
  937. $info['specinfo'] = json_decode($info['specinfo'],true);
  938. $info['metal_name']=isset($info['metal_id'])&& $info['metal_id']!=0?$this->noble[$info['metal_id']]:"";
  939. $bargain =Db::name("bargain_order")->where(['bidsNo'=>$bidNo,"is_del"=>0])->find();
  940. $info['bargain'] =$bargain;
  941. return app_show(0,"获取成功",$info);
  942. }
  943. public function feededit(){
  944. $bidNo= isset($this->post['bidNo'])&&$this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  945. if($bidNo==""){
  946. return error_show(1002,"参数bidNo不能为空");
  947. }
  948. $bidinfo = Db::name("consult_bids")->where(["bidNo"=>$bidNo,"is_del"=>0])->find();
  949. if($bidinfo==false){
  950. return error_show(1003,"未找到信息数据");
  951. }
  952. if($bidinfo['status']>=5){
  953. return error_show(1004,"咨询单已确认无法修改");
  954. }
  955. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$bidinfo['infoNo'],"is_del"=>0])->find();
  956. if($zxinfo==false){
  957. return error_show(1003,"未找到信息数据");
  958. }
  959. $zx = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
  960. if($zx==false){
  961. return error_show(1003,"未找咨询信息数据");
  962. }
  963. $pname = isset($this->post['pname'])&&$this->post['pname']!=""? trim($this->post['pname']):"";
  964. if($pname==""){
  965. return error_show(1002,"参数pname不能为空");
  966. }
  967. $brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):"";
  968. // if($brandid==""){
  969. // return error_show(1002,"参数brandid不能为空");
  970. // }
  971. $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? trim($this->post['cat_id']):"";
  972. if($cat_id==""){
  973. return error_show(1002,"参数cat_id不能为空");
  974. }
  975. $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
  976. if($specin==""){
  977. return error_show(1003,"参数specinfo不能为空");
  978. }
  979. $specinfo=[];
  980. foreach ($specin as $v){
  981. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  982. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  983. $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
  984. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
  985. $specinfo[]=$v;
  986. }
  987. $unit_id = isset($this->post['unit_id'])&&$this->post['unit_id']!=""? intval($this->post['unit_id']):"";
  988. $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""? trim($this->post['cost_desc']):"";
  989. $work_day = isset($this->post['work_day'])&&$this->post['work_day']!=""? intval($this->post['work_day']):"";
  990. $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!=""? intval($this->post['delivery_day']):"";
  991. $good_img = isset($this->post['good_img'])&&$this->post['good_img']!=""? trim($this->post['good_img']):"";
  992. $expire_day = isset($this->post['expire_day'])&&$this->post['expire_day']!=""? intval($this->post['expire_day'])
  993. :"";
  994. $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!=""? trim($this->post['origin_place']):"";
  995. $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
  996. $pay_way = isset($this->post['pay_way'])&&$this->post['pay_way']!=""? intval($this->post['pay_way']):"";
  997. $tax = isset($this->post['tax'])&&$this->post['tax']!=""? trim($this->post['tax']):"";
  998. $send_way = isset($this->post['send_way'])&&$this->post['send_way']!=""? intval($this->post['send_way']):"";
  999. $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!=""? intval($this->post['metal_id']):"";
  1000. $is_gold_price = isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!=""? intval($this->post['is_gold_price']):"";
  1001. $config = isset($this->post['config'])&&$this->post['config']!=""? $this->post['config']:"";
  1002. $other_config = isset($this->post['other_config'])&&$this->post['other_config']!=""? $this->post['other_config']:"";
  1003. $weight = isset($this->post['weight'])&&$this->post['weight']!=""? floatval($this->post['weight']):"";
  1004. $demo_fee = isset($this->post['demo_fee'])&&$this->post['demo_fee']!=""? floatval($this->post['demo_fee']):"";
  1005. $delivery_fee = isset($this->post['delivery_fee'])&&$this->post['delivery_fee']!=""? floatval($this->post['delivery_fee']):"";
  1006. $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!=""? floatval($this->post['open_fee']):"";
  1007. $pakge_fee = isset($this->post['pakge_fee'])&&$this->post['pakge_fee']!=""? floatval($this->post['pakge_fee']):"";
  1008. $nake_fee = isset($this->post['nake_fee'])&&$this->post['nake_fee']!==""? floatval($this->post['nake_fee']):"";
  1009. if($nake_fee==="" ||$nake_fee==0 ){
  1010. return error_show(1004,"参数nake_fee不能为空或零");
  1011. }
  1012. $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!=""? floatval($this->post['mark_fee']):"";
  1013. $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!=""? floatval($this->post['cert_fee']):"";
  1014. $cost_fee = isset($this->post['cost_fee'])&&$this->post['cost_fee']!=""? floatval($this->post['cost_fee']):"";
  1015. $total_fee = isset($this->post['total_fee'])&&$this->post['total_fee']!=""? floatval($this->post['total_fee']):"";
  1016. $is_diff = isset($this->post['is_diff'])&&$this->post['is_diff']!==""? intval($this->post['is_diff']):"";
  1017. $supply_area = isset($this->post['supply_area'])&&$this->post['supply_area']!==""? intval($this->post['supply_area']):"";
  1018. $remark = isset($this->post['remark'])&&$this->post['remark']!=""? trim($this->post['remark']):"";
  1019. $catinfo = Db::name("cat")->where(["id"=>$cat_id])->find();
  1020. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:0;
  1021. if($is_gold_price==1){
  1022. $gold = Db::name("gold_price1")->where(["type"=>$metal_id,"is_del"=>0,"status"=>1])->order("addtime desc")
  1023. ->find();
  1024. $total_fee = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee*
  1025. $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  1026. $saleprice = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee/(1-$budget)*
  1027. $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  1028. }else{
  1029. $saleprice = $open_fee/$zxinfo['num'] +
  1030. $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee/(1-$budget);
  1031. $total_fee = $open_fee/$zxinfo['num'] +
  1032. $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  1033. }
  1034. Db::startTrans();
  1035. try{
  1036. $data=[
  1037. "good_name"=>$pname,
  1038. "brand_id"=>$brandid,
  1039. "cat_id"=>$cat_id,
  1040. "specinfo"=>json_encode($specinfo),
  1041. // "material"=>$material,
  1042. "unit_id"=>$unit_id,
  1043. "cost_desc"=>$cost_desc,
  1044. "work_day"=>$work_day,
  1045. "delivery_day"=>$delivery_day,
  1046. "good_img"=>$good_img,
  1047. "expire_day"=>$expire_day,
  1048. "origin_place"=>$origin_place,
  1049. "supplierNo"=>$supplierNo,
  1050. "pay_way"=>$pay_way,
  1051. "tax"=>$tax,
  1052. "send_way"=>$send_way,
  1053. "metal_id"=>$metal_id,
  1054. "is_gold_price"=>$is_gold_price,
  1055. "config"=>$config,
  1056. "other_config"=>$other_config,
  1057. "weight"=>$weight,
  1058. "is_diff"=>$is_diff,
  1059. "demo_fee"=>$demo_fee,
  1060. "delivery_fee"=>$delivery_fee,
  1061. "open_fee"=>$open_fee,
  1062. "pakge_fee"=>$pakge_fee,
  1063. "nake_fee"=>$nake_fee,
  1064. "mark_fee"=>$mark_fee,
  1065. "cert_fee"=>$cert_fee,
  1066. "cost_fee"=>$cost_fee,
  1067. "total_fee"=>$total_fee,
  1068. "sale_price"=>$saleprice,
  1069. "supply_area"=>$supply_area,
  1070. "remark"=>$remark,
  1071. "updatetime"=>date("Y-m-d H:i:s")
  1072. ];
  1073. $insert= Db::name("consult_bids")->where($bidinfo)->save($data);
  1074. if($insert){
  1075. if($zx['is_project']==1 && $zx['projectNo']!="" && $zxinfo['pgNo']!=""){
  1076. $projectinfo =Db::name("project_info")->where(["pgNo"=>$zxinfo["pgNo"],"projectNo"=>$zx['projectNo'],"is_del"=>0])->find();
  1077. if($projectinfo==false){
  1078. Db::rollback();
  1079. return error_show(1006,"未找到项目信息");
  1080. }
  1081. $feed = Db::name("project_feedback")->where(["pgNo"=>$zxinfo["pgNo"],"projectNo"=>$zx['projectNo'],"spuCode"=>$bidinfo['spuCode'],"is_del"=>0])->find();
  1082. if($feed==false){
  1083. Db::rollback();
  1084. return error_show(1006,"未找到项目反馈信息");
  1085. }
  1086. $feed['good_name']=$pname;
  1087. $feed['good_type']=$projectinfo['good_type'];
  1088. $feed['cat_id']=$cat_id;
  1089. $feed['sale_price']=$saleprice;
  1090. $feed['origin_price']=$total_fee;
  1091. $temp['updatetime']=date("Y-m-d H:i:s");
  1092. $nu = Db::name("project_feedback")->save($feed);
  1093. if($nu==false){
  1094. Db::rollback();
  1095. return error_show(1006,"项目反馈失败");
  1096. }else{
  1097. $projectinfo['status']=2;
  1098. $projectinfo['updatetime']=date("Y-m-d H:i:s");
  1099. $up = Db::name("project_info")->save($projectinfo);
  1100. if($up){
  1101. $count = Db::name("project_info")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])
  1102. ->count();
  1103. if($count==0){
  1104. $proc =Db::name("project")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])->save
  1105. (["status"=>2,"updatetime"=>date("Y-m-d H:i:s")]);
  1106. if($proc==false){
  1107. Db::rollback();
  1108. return error_show(1006,"项目反馈失败");
  1109. }
  1110. }
  1111. }
  1112. }
  1113. }
  1114. Db::commit();
  1115. return app_show(0,"编辑成功");
  1116. }else{
  1117. Db::rollback();
  1118. return error_show(1004,"编辑失败");
  1119. }
  1120. }catch (\Exception $e){
  1121. Db::rollback();
  1122. return error_show(1004,$e->getMessage());
  1123. }
  1124. }
  1125. public function bargain_add(){
  1126. $bidNo = isset($this->post['bidNo'])&& $this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  1127. if($bidNo===""){
  1128. return error_show(1004,"参数bidNo不能为空");
  1129. }
  1130. $info =Db::name("consult_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
  1131. if($info==false){
  1132. return error_show(1004,"未找到商品数据");
  1133. }
  1134. $bargain_price = isset($this->post['bargain_price'])&& $this->post['bargain_price']!=""?floatval($this->post['bargain_price']):"";
  1135. if($bargain_price===""){
  1136. return error_show(1004,"参数bargain_price不能为空");
  1137. }
  1138. $bargain_reason = isset($this->post['bargain_reason'])&& $this->post['bargain_reason']!=""?trim($this->post['bargain_reason']):"";
  1139. // if($bargain_reason===""){
  1140. // return error_show(1004,"参数bargain_reason不能为空");
  1141. // }
  1142. $infos =Db::name("consult_info")->where(['infoNo'=>$info['infoNo'],"is_del"=>0])->find();
  1143. if($infos==false){
  1144. return error_show(1004,"未找到商品数据");
  1145. }
  1146. if($infos['status']!=2&&$infos['status']!=3&&$infos['status']!=7){
  1147. return error_show(1004,"咨询单招标未结束或已确认商品");
  1148. }
  1149. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1150. if($token==''){
  1151. return error_show(105,"参数token不能为空");
  1152. }
  1153. $user =GetUserInfo($token);
  1154. if(empty($user)||$user['code']!=0){
  1155. return error_show(1002,"用户数据不存在");
  1156. }
  1157. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1158. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1159. $bargainNo =makeNo("BA");
  1160. Db::startTrans();//::todo 金价 毛利计算
  1161. try{
  1162. $data=[
  1163. "bidsNo"=>$bidNo,
  1164. "infoNo"=>$info['infoNo'],
  1165. "zxNo"=>$info['zxNo'],
  1166. "bargainNo"=>$bargainNo,
  1167. "bargain_type"=>1,
  1168. "bargain_reason"=>$bargain_reason,
  1169. "sale_price"=>$info['sale_price'],
  1170. "cost_before_price"=>$info['cost_fee'],
  1171. "cost_after_price"=>$info['cost_fee'],
  1172. "before_rate"=>$info['cost_fee'],
  1173. "after_rate"=>$info['cost_fee'],
  1174. "after_price"=>$bargain_price,
  1175. "exam_info"=>"",
  1176. "status"=>1,
  1177. "is_del"=>0,
  1178. "creater"=>$creater,
  1179. "createrid"=>$createrid,
  1180. "addtime"=>date("Y-m-d H:i:s"),
  1181. "updatetime"=>date("Y-m-d H:i:s")
  1182. ];
  1183. $int = Db::name("bargain_order")->insert($data);
  1184. if($int){
  1185. $info['status']=3;
  1186. $info['updatetime']=date("Y-m-d H:i:s");
  1187. $up =Db::name("consult_bids")->save($info);
  1188. if($up){
  1189. $infos['status']=3;
  1190. $infos['updatetime']=date("Y-m-d H:i:s");
  1191. $ups =Db::name("consult_info")->save($infos);
  1192. if($ups){
  1193. Db::commit();
  1194. return app_show(0,"议价单生成成功",["bargainNo"=>$bargainNo]);
  1195. }
  1196. }
  1197. }
  1198. Db::rollback();
  1199. return error_show(1004,"议价单新建失败");
  1200. }catch (\Exception $e){
  1201. Db::rollback();
  1202. return error_show(1004,$e->getMessage());
  1203. }
  1204. }
  1205. public function bids_check(){
  1206. $bidNo = isset($this->post['bidNo'])&& $this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  1207. if($bidNo===""){
  1208. return error_show(1004,"参数bidNo不能为空");
  1209. }
  1210. $info =Db::name("consult_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
  1211. if($info==false){
  1212. return error_show(1004,"未找到商品数据");
  1213. }
  1214. $infos =Db::name("consult_info")->where(['infoNo'=>$info['infoNo'],"is_del"=>0])->find();
  1215. if($infos==false){
  1216. return error_show(1004,"未找到商品数据");
  1217. }
  1218. if($infos['status']!=2&&$infos['status']!=3&&$infos['status']!=7){
  1219. return error_show(1004,"咨询单招标未结束或已确认商品");
  1220. }
  1221. Db::startTrans();
  1222. try {
  1223. $info['status']=6;
  1224. $info['updatetime']=date("Y-m-d H:i:s");
  1225. $bids = Db::name("consult_bids")->save($info);
  1226. if($bids){
  1227. $infos['status']=4;
  1228. $infos['updatetime']=date("Y-m-d H:i:s");
  1229. $se = Db::name("consult_info")->save($infos);
  1230. if($se){
  1231. Db::commit();
  1232. return app_show(0,"商品确定成功");
  1233. }
  1234. }
  1235. Db::rollback();
  1236. return error_show(1004,"商品确认失败");
  1237. }catch (\Exception $e){
  1238. Db::rollback();
  1239. return error_show(1004,$e->getMessage());
  1240. }
  1241. }
  1242. public function bargain_status(){
  1243. $bargainNo = isset($this->post['bargainNo'])&& $this->post['bargainNo']!=""?trim($this->post['bargainNo']):"";
  1244. if($bargainNo===""){
  1245. return error_show(1004,"参数bargainNo不能为空");
  1246. }
  1247. $info =Db::name("bargain_order")->where(['bargainNo'=>$bargainNo,"is_del"=>0])->find();
  1248. if($info==false){
  1249. return error_show(1004,"未找到议价数据");
  1250. }
  1251. $bids=Db::name("consult_bids")->where(["bidNo"=>$info["bidsNo"],"is_del"=>0])->find();
  1252. if($bids==false){
  1253. return error_show(1004,"未找到商品数据");
  1254. }
  1255. $coninfo=Db::name("consult_info")->where(["infoNo"=>$bids["infoNo"],"is_del"=>0])->find();
  1256. if($coninfo==false){
  1257. return error_show(1004,"未找到咨询单数据");
  1258. }
  1259. $status = isset($this->post['status'])&& $this->post['status']!=='' ? intval($this->post['status']):"";
  1260. if($status==''){
  1261. return error_show(1005,"参数status不能为空");
  1262. }
  1263. $remark = isset($this->post['remark'])&& $this->post['remark']!=""?trim($this->post['remark']):"";
  1264. // if($remark==""){
  1265. // return error_show(1004,"参数remark不能为空");
  1266. // }
  1267. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1268. if($token==''){
  1269. return error_show(105,"参数token不能为空");
  1270. }
  1271. $user =GetUserInfo($token);
  1272. if(empty($user)||$user['code']!=0){
  1273. return error_show(1002,"用户数据不存在");
  1274. }
  1275. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1276. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1277. Db::startTrans();
  1278. try{
  1279. $examinfo = isset($info['exam_info'])&&$info['exam_info']!="" ? json_decode($info['exam_info'],true):[];
  1280. $examinfo[]=["status"=>$status,"remark"=>$remark,"createrid"=>$createrid,"creater"=>$creater];
  1281. $info['status'] =$status;
  1282. $info['remark'] =$remark;
  1283. $info['exam_info']=json_encode($examinfo) ;
  1284. $info['updatetime'] =date("Y-m-d H:i:s");
  1285. $up =Db::name("bargain_order")->save($info);
  1286. if($up){
  1287. if($status==4||$status==5||$status==6||$status==7){
  1288. $bids['status']=5;
  1289. if($status==4){
  1290. $bids['sale_price']=$info['after_price'];
  1291. }
  1292. $bids['updatetime']=date("Y-m-d H:i:s");
  1293. $up =Db::name("consult_bids")->save($bids);
  1294. if($up==false){
  1295. Db::rollback();
  1296. return error_show(1004,"数据更新失败");
  1297. }
  1298. }
  1299. Db::commit();
  1300. return app_show(0,"更新成功");
  1301. }
  1302. }catch (\Exception $e){
  1303. Db::rollback();
  1304. return error_show(1004,$e->getMessage());
  1305. }
  1306. }
  1307. public function bargain_info(){
  1308. $bargainNo = isset($this->post['bargainNo'])&& $this->post['bargainNo']!=""?trim($this->post['bargainNo']):"";
  1309. if($bargainNo===""){
  1310. return error_show(1004,"参数bargainNo不能为空");
  1311. }
  1312. $info =Db::name("bargain_order")->where(['bargainNo'=>$bargainNo,"is_del"=>0])->find();
  1313. if($info==false){
  1314. return error_show(1004,"未找到议价数据");
  1315. }
  1316. $bidinfos = Db::name("consult_bids")->where([["bidNo","=",$info['bidsNo']],["is_del","=",0]])->find();
  1317. if($bidinfos==false){
  1318. return error_show(1004,"未找到商品数据");
  1319. }
  1320. $consultinfos = Db::name("consult_info")->where([["infoNo","=",$bidinfos['infoNo']],["is_del","=",0]])
  1321. ->find();
  1322. if($consultinfos==false){
  1323. return error_show(1004,"未找到咨询商品数据");
  1324. }
  1325. $info['spuCode'] = isset($bidinfos['spuCode'])?$bidinfos['spuCode']:"";
  1326. $info['good_name'] = isset($bidinfos['good_name'])?$bidinfos['good_name']:"";
  1327. $info['good_img'] = isset($bidinfos['good_img'])?$bidinfos['good_img']:"";
  1328. $info['brand_id'] = isset($bidinfos['brand_id'])?$bidinfos['brand_id']:"";
  1329. $info['good_num'] = isset($consultinfos['num'])?$consultinfos['num']:"";
  1330. $info['exam_info'] = isset($info['exam_info'])&&$info['exam_info']!=""?json_encode($info['exam_info']):"";
  1331. if($bidinfos['brand_id']!=0){
  1332. $info['brand_id'] = $bidinfos['brand_id'];
  1333. $brand=Db::name("brand")->where(["id"=>$bidinfos['brand_id']])->find();
  1334. $info["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1335. }else{
  1336. $info["brand_name"]="";
  1337. $info["brand_id"]="";
  1338. }
  1339. $catinfo = Db::name("cat")->where(["id"=>$bidinfos['cat_id']])->find();
  1340. $info['can']= isset($bidinfos['cat_id']) && $bidinfos['cat_id'] !=0 ? made($bidinfos['cat_id']):[];
  1341. $unit =Db::name("unit")->where(["id"=>$bidinfos['unit_id']])->find();
  1342. $info['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1343. $bidinfoe = Db::name("consult_info")->where(["infoNo"=>$info["infoNo"]])->find();
  1344. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
  1345. $info['budget'] =$budget;
  1346. $god=[
  1347. "metal_id"=>$bidinfos['metal_id'],
  1348. "weight"=>$bidinfos["weight"],
  1349. "demo_fee"=>$bidinfos["demo_fee"],
  1350. "delivery_fee"=>$bidinfos["delivery_fee"],
  1351. "open_fee"=>$bidinfos["open_fee"],
  1352. "packing_fee"=>$bidinfos["pakge_fee"],
  1353. "mark_fee"=>$bidinfos["mark_fee"],
  1354. "nake_fee"=>$bidinfos["nake_fee"],
  1355. "cert_fee"=>$bidinfos["cert_fee"],
  1356. "cost_fee"=>$bidinfos["cost_fee"],
  1357. "num"=>$bidinfoe["num"],
  1358. ];
  1359. $info['gold_price']=0;
  1360. if($bidinfos['is_gold_price']==1 &&$bidinfos['metal_id']>0){
  1361. $gold = Db::name("gold_price1")->where(["type"=>$bidinfos["metal_id"],"is_del"=>0,"status"=>1])->order("addtime desc")
  1362. ->find();
  1363. $info['gold_price'] =$gold['price'];
  1364. }
  1365. $info['cost_desc'] =$bidinfos['cost_desc'];
  1366. $info['work_day'] =$bidinfos['work_day'];
  1367. $info['delivery_day'] =$bidinfos['delivery_day'];
  1368. $info['expire_day'] =$bidinfos['expire_day'];
  1369. $info['origin_place'] =$bidinfos['origin_place'];
  1370. $info['origin_addr'] ="";
  1371. if($bidinfos['origin_place']!=''){
  1372. $code = explode(",",$bidinfos['origin_place']);
  1373. $temp=[];
  1374. $temp['provice_code']=isset($code[0])?$code[0]:"";
  1375. $temp['city_code']=isset($code[1])?$code[1]:"";
  1376. $temp['area_code']=isset($code[2])?$code[2]:"";
  1377. $addr= GetAddr(json_encode($temp));
  1378. $info['origin_addr'] = $addr;
  1379. }
  1380. $info['supplierNo'] =$bidinfos['supplierNo'];
  1381. $supplier = Db::name("supplier")->where(["code"=>$info['supplierNo']])->find();
  1382. $info['supplier_name'] = isset($supplier['name'])?$supplier['name']:"";
  1383. $info['pay_way'] =$bidinfos['pay_way'];
  1384. $info['tax'] =$bidinfos['tax'];
  1385. $info['send_way'] =$bidinfos['send_way'];
  1386. $info['metal_id'] =$bidinfos['metal_id'];
  1387. $info['is_gold_price'] =$bidinfos['is_gold_price'];
  1388. $info['config'] =$bidinfos['config'];
  1389. $info['other_config'] =$bidinfos['other_config'];
  1390. $info['weight'] =$bidinfos['weight'];
  1391. $info['is_diff'] =$bidinfos['is_diff'];
  1392. $info['demo_fee'] =$bidinfos['demo_fee'];
  1393. $info['delivery_fee'] =$bidinfos['delivery_fee'];
  1394. $info['open_fee'] =$bidinfos['open_fee'];
  1395. $info['pakge_fee'] =$bidinfos['pakge_fee'];
  1396. $info['nake_fee'] =$bidinfos['nake_fee'];
  1397. $info['mark_fee'] =$bidinfos['mark_fee'];
  1398. $info['cert_fee'] =$bidinfos['cert_fee'];
  1399. $info['cost_fee'] =$bidinfos['cost_fee'];
  1400. $info['total_fee'] =$bidinfos['total_fee'];
  1401. $info['supply_area'] =$bidinfos['supply_area'];
  1402. $info['remark'] =$bidinfos['remark'];
  1403. $info['is_addrs'] =$consultinfos['is_addrs'];
  1404. $info['is_custom'] =$consultinfos['is_custom'];
  1405. $info['metal_name']=isset($bidinfos['metal_id'])&& $bidinfos['metal_id']!=0?$this->noble[$bidinfos['metal_id']]:"";
  1406. $info['sale_price'] =round($bidinfos['sale_price'],2);
  1407. $info['specinfo'] = isset($bidinfos['specinfo'])&&$bidinfos['specinfo']!=""?json_decode($bidinfos['specinfo'],true):[];
  1408. return app_show(0,"获取成功",$info);
  1409. }
  1410. public function bidlist(){
  1411. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  1412. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  1413. $where=[['is_del',"=",0]];
  1414. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1415. if ($zxNo !== "") {
  1416. $where[] = ['zxNo','=',$zxNo];
  1417. }
  1418. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  1419. if ($infoNo !== "") {
  1420. $where[] = ['infoNo','=',$infoNo];
  1421. }
  1422. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
  1423. if ($bidNo !== "") {
  1424. $where[] = ['bidNo','=',$bidNo];
  1425. }
  1426. $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
  1427. if ($pgNo !== "") {
  1428. $bidinfo = Db::name("consult_info")->where([["pgNo","=",$pgNo],["is_del","=",0]])->column("infoNo");
  1429. $where[] = ['infoNo','in',$bidinfo];
  1430. }
  1431. $bargain_status = isset($this->post['bargain_status']) && $this->post['bargain_status'] !== "" ? intval($this->post['bargain_status']) : "";
  1432. if ($bargain_status !== "") {
  1433. $bidinfo = Db::name("consult_info")->where([["bargain_status","=",$bargain_status],["is_del","=",0]])->column("infoNo");
  1434. $where[] = ['infoNo','in',$bidinfo];
  1435. }
  1436. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  1437. if ($projectNo !== "") {
  1438. $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column
  1439. ("zxNo");
  1440. $where[] = ['zxNo','in',$zxlist];
  1441. }
  1442. $count = Db::name('consult_bids')->where($where)->count();
  1443. $total = ceil($count / $size);
  1444. $page = $page >= $total ? $total : $page;
  1445. $list =Db::name('consult_bids')->where($where)->page($page,$size)->select();
  1446. $data=[];
  1447. foreach ($list as $value){
  1448. $catinfo = Db::name("cat")->where(["id"=>$value['cat_id']])->find();
  1449. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  1450. $unit =Db::name("unit")->where(["id"=>$value['unit_id']])->find();
  1451. $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1452. $supplier = Db::name("supplier")->where(["code"=>$value['supplierNo']])->find();
  1453. $value['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  1454. if($value['brand_id']!=0){
  1455. $brand=Db::name("brand")->where(["id"=>$value['brand_id']])->find();
  1456. $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1457. }else{
  1458. $value["brand_name"]="";
  1459. $value["brand_id"]="";
  1460. }
  1461. $bidinfo = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
  1462. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
  1463. $god=[
  1464. "metal_id"=>$value['metal_id'],
  1465. "weight"=>$value["weight"],
  1466. "demo_fee"=>$value["demo_fee"],
  1467. "delivery_fee"=>$value["delivery_fee"],
  1468. "open_fee"=>$value["open_fee"],
  1469. "packing_fee"=>$value["pakge_fee"],
  1470. "mark_fee"=>$value["mark_fee"],
  1471. "nake_fee"=>$value["nake_fee"],
  1472. "cert_fee"=>$value["cert_fee"],
  1473. "cost_fee"=>$value["cost_fee"],
  1474. "num"=>$bidinfo["num"],
  1475. ];
  1476. if($value['is_gold_price']==1){
  1477. $price = GoldPrice($god, $budget/100);
  1478. $value['sale_price'] = round($price,2);
  1479. }
  1480. $value['specinfo'] = json_decode($value['specinfo'],true);
  1481. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  1482. $value['bargain_status']=$bidinfo['bargain_status'];
  1483. $data[]=$value;
  1484. }
  1485. return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
  1486. }
  1487. public function feedlist(){
  1488. $where=[['is_del',"=",0]];
  1489. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1490. if ($zxNo !== "") {
  1491. $where[] = ['zxNo','=',$zxNo];
  1492. }
  1493. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  1494. if ($infoNo !== "") {
  1495. $where[] = ['infoNo','=',$infoNo];
  1496. }
  1497. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
  1498. if ($bidNo !== "") {
  1499. $where[] = ['bidNo','=',$bidNo];
  1500. }
  1501. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  1502. if ($projectNo !== "") {
  1503. $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column
  1504. ("zxNo");
  1505. $where[] = ['zxNo','in',$zxlist];
  1506. }
  1507. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1508. if($token==''){
  1509. return error_show(102,"参数token不能为空");
  1510. }
  1511. $user =GetUserInfo($token);
  1512. if(empty($user)||$user['code']!=0){
  1513. return error_show(105,"用户数据不存在");
  1514. }
  1515. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1516. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1517. $where[] = ["createrid","=",$createrid];
  1518. $list =Db::name('consult_bids')->where($where)->select();
  1519. $data=[];
  1520. foreach ($list as $value){
  1521. $catinfo = Db::name("cat")->where(["id"=>$value['cat_id']])->find();
  1522. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  1523. $unit =Db::name("unit")->where(["id"=>$value['unit_id']])->find();
  1524. $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1525. $supplier = Db::name("supplier")->where(["code"=>$value['supplierNo']])->find();
  1526. $value['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  1527. if($value['brand_id']!=0){
  1528. $brand=Db::name("brand")->where(["id"=>$value['brand_id']])->find();
  1529. $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1530. }else{
  1531. $value["brand_name"]="";
  1532. $value["brand_id"]="";
  1533. }
  1534. $bidinfo = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
  1535. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
  1536. $god=[
  1537. "metal_id"=>$value['metal_id'],
  1538. "weight"=>$value["weight"],
  1539. "demo_fee"=>$value["demo_fee"],
  1540. "delivery_fee"=>$value["delivery_fee"],
  1541. "open_fee"=>$value["open_fee"],
  1542. "packing_fee"=>$value["pakge_fee"],
  1543. "mark_fee"=>$value["mark_fee"],
  1544. "nake_fee"=>$value["nake_fee"],
  1545. "cert_fee"=>$value["cert_fee"],
  1546. "cost_fee"=>$value["cost_fee"],
  1547. "num"=>$bidinfo["num"],
  1548. ];
  1549. if($value['is_gold_price']==1){
  1550. $price = GoldPrice($god, $budget/100);
  1551. $value['sale_price'] =round($price,2);
  1552. }
  1553. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  1554. $value['specinfo'] = json_decode($value['specinfo'],true);
  1555. $value['bargain_status']=$bidinfo['bargain_status'];
  1556. $data[]=$value;
  1557. }
  1558. return app_show(0,"获取成功",$data);
  1559. }
  1560. public function bragain_list(){
  1561. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  1562. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  1563. $where=[['is_del',"=",0]];
  1564. $bidsNo = isset($this->post['bidsNo'])&&$this->post['bidsNo']!=""?trim($this->post['bidsNo']):"";
  1565. if($bidsNo!=""){
  1566. $where[]=["bidsNo","=",$bidsNo];
  1567. }
  1568. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1569. if ($zxNo !== "") {
  1570. $where[] = ['zxNo','=',$zxNo];
  1571. }
  1572. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  1573. if ($infoNo !== "") {
  1574. $where[] = ['infoNo','=',$infoNo];
  1575. }
  1576. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  1577. if ($projectNo !== "") {
  1578. $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column
  1579. ("zxNo");
  1580. $where[] = ['zxNo','in',$zxlist];
  1581. }
  1582. $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
  1583. if ($pgNo !== "") {
  1584. $bidinfo = Db::name("consult_info")->where([["pgNo","=",$pgNo],["is_del","=",0]])->column("infoNo");
  1585. $where[] = ['infoNo','in',$bidinfo];
  1586. }
  1587. $count=Db::name("bargain_order")->where($where)->count();
  1588. $total = ceil($count / $size);
  1589. $page = $page >= $total ? $total : $page;
  1590. $list =Db::name('bargain_order')->where($where)->page($page,$size)->select();
  1591. $data=[];
  1592. foreach ($list as $value){
  1593. $bidinfos = Db::name("consult_bids")->where([["bidNo","=",$value['bidsNo']],["is_del","=",0]])->find();
  1594. $value['spuCode'] = isset($bidinfos['spuCode'])?$bidinfos['spuCode']:"";
  1595. $value['good_name'] = isset($bidinfos['good_name'])?$bidinfos['good_name']:"";
  1596. $value['good_img'] = isset($bidinfos['good_img'])?$bidinfos['good_img']:"";
  1597. $value['brand_id'] = isset($bidinfos['brand_id'])?$bidinfos['brand_id']:"";
  1598. if($bidinfos['brand_id']!=0){
  1599. $value['brand_id'] = $bidinfos['brand_id'];
  1600. $brand=Db::name("brand")->where(["id"=>$bidinfos['brand_id']])->find();
  1601. $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1602. }else{
  1603. $value["brand_name"]="";
  1604. $value["brand_id"]="";
  1605. }
  1606. $catinfo = Db::name("cat")->where(["id"=>$bidinfos['cat_id']])->find();
  1607. $value['can']= isset($bidinfos['cat_id']) && $bidinfos['cat_id'] !=0 ? made($bidinfos['cat_id']):[];
  1608. $unit =Db::name("unit")->where(["id"=>$bidinfos['unit_id']])->find();
  1609. $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1610. $bidinfoe = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
  1611. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
  1612. $value['budget'] =$budget;
  1613. $god=[
  1614. "metal_id"=>$bidinfos['metal_id'],
  1615. "weight"=>$bidinfos["weight"],
  1616. "demo_fee"=>$bidinfos["demo_fee"],
  1617. "delivery_fee"=>$bidinfos["delivery_fee"],
  1618. "open_fee"=>$bidinfos["open_fee"],
  1619. "packing_fee"=>$bidinfos["pakge_fee"],
  1620. "mark_fee"=>$bidinfos["mark_fee"],
  1621. "nake_fee"=>$bidinfos["nake_fee"],
  1622. "cert_fee"=>$bidinfos["cert_fee"],
  1623. "cost_fee"=>$bidinfos["cost_fee"],
  1624. "num"=>$bidinfoe["num"],
  1625. ];
  1626. // if($bidinfos['is_gold_price']==1){
  1627. // $price = GoldPrice($god, $budget/100);
  1628. // }else{
  1629. // $price = GoodPrice($god, $budget/100);
  1630. // }
  1631. $value['metal_name']=isset($bidinfos['metal_id'])&& $bidinfos['metal_id']!=0?$this->noble[$bidinfos['metal_id']]:"";
  1632. $value['sale_price'] =round($bidinfos['sale_price'],2);
  1633. $value['specinfo'] = isset($bidinfos['specinfo'])&&$bidinfos['specinfo']!=""?json_decode($bidinfos['specinfo'],true):[];
  1634. $data[]=$value;
  1635. }
  1636. return app_show(0,"获取成功",["list"=>$data,"count"=>$count]);
  1637. }
  1638. public function crontablist(){
  1639. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  1640. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  1641. $where=[['a.is_del',"=",0],['b.is_del',"=",0]];
  1642. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1643. if ($zxNo !== "") {
  1644. $where[] = ['a.zxNo','=',$zxNo];
  1645. }
  1646. $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
  1647. if ($salesman !== "") {
  1648. //$where["salesman"] =Db::Raw("like '%$salesman%'");
  1649. $where[]= ["b.salesman",'like',"%$salesman%"];
  1650. }
  1651. $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : "";
  1652. if ($cpName !== "") {
  1653. //$where["cpName"]= Db::Raw("like '%$cpName%'");
  1654. $where[]= ["a.good_Name",'like',"%$cpName%"];
  1655. }
  1656. $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
  1657. if ($khNo !== "") {
  1658. // $where['khNo'] = $khNo;
  1659. $where[]= ["b.khNo",'like',"%$khNo%"];
  1660. }
  1661. $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
  1662. if ($start !="") {
  1663. //$where = ["zxtime"=>Db::raw(">= '{$start}'")];
  1664. $where[]= ["a.addtime",'>=',$start];
  1665. }
  1666. $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
  1667. if($end !=""){
  1668. $where[]= ["a.addtime",'<=',$end];
  1669. }
  1670. $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
  1671. if ($status !== "") {
  1672. $where[]= ["a.status",'=',$status];
  1673. }
  1674. $count = Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)
  1675. ->count();
  1676. $total = ceil($count / $size);
  1677. $page = $page >= $total ? $total : $page;
  1678. $list =Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)->page($page,$size)
  1679. ->field("a.*,b.createrid,b.creater,b.is_project,b.projectNo,b.khNo,b.endtime,b.platform_code,b.saleid,b.salesman,b.depart")->select();
  1680. $data=[];
  1681. foreach ($list as $value){
  1682. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  1683. $brand = Db::name("brand")->where(['id'=>$value['brand_id']])->find();
  1684. $value['brand_name']= isset($brand['brand_name']) && $brand['brand_name']!='' ? $brand['brand_name']:"";
  1685. $value['khname']="";
  1686. $value['specinfo']=isset($value['specinfo'])&&$value['specinfo']!=""? json_decode($value['specinfo'],
  1687. true):[];
  1688. if($value['khNo']!==""){
  1689. $kh=Db::name("customer_info")->where(['companyNo'=>$value['khNo']])->find();
  1690. $value['khname']= isset($kh['companyName'])?$kh['companyName']:"";
  1691. }
  1692. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  1693. $data[]=$value;
  1694. }
  1695. return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
  1696. }
  1697. }