Consult.php 80 KB

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