Consult.php 78 KB

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