Consult.php 108 KB

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