Consult.php 85 KB

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