Consult.php 90 KB

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