Consult.php 88 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728
  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['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['sale_price'] =$value['total_price'];
  650. $value['status'] =0;
  651. $value['updatetime'] =date("Y-m-d H:i:s");
  652. $in = Db::name("consult_bids")->insert($value);
  653. if($in==false){
  654. Db::rollback();
  655. return error_show(1004,"反馈商品新建失败");
  656. }
  657. }
  658. }
  659. $zxinfo["bargain_status"] =1;
  660. $zxinfo["bargain_code"] =$innew;
  661. $zxinfo["updatetime"] =date("Y-m-d H:i:s");
  662. $bar=Db::name("consult_info")->save($zxinfo);
  663. if($bar==false){
  664. Db::rollback();
  665. return error_show(1004,"反馈商品更新失败");
  666. }
  667. Db::commit();
  668. return app_show(0,"咨询新建成功",["infoNo"=>$innew]);
  669. }
  670. }catch (\Exception $e){
  671. Db::rollback();
  672. return error_show(1004,$e->getMessage());
  673. }
  674. }
  675. //** 发布竞标任务 */
  676. public function bargain(){
  677. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  678. if($infoNo==""){
  679. return error_show(1004,"参数infoNo不能为空");
  680. }
  681. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  682. if($zxinfo==false){
  683. return error_show(1004,"未找到信息数据");
  684. }
  685. $status =isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
  686. if($status===""){
  687. return error_show(1004,"参数status不能为空");
  688. }
  689. if($status==1&&$zxinfo['status']>1){
  690. $zxinfo['bargain_num']=+1;
  691. }
  692. $zxinfo['status']=$status;
  693. $zxinfo['updatetime']=date("Y-m-d H:i:s");
  694. $up = Db::name("consult_info")->save($zxinfo);
  695. if($up){
  696. return app_show(0,"状态更新成功");
  697. }else{
  698. return error_show(1003,"状态更新失败");
  699. }
  700. }
  701. public function feadback(){
  702. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  703. if($infoNo==""){
  704. return error_show(1002,"参数infoNo不能为空");
  705. }
  706. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  707. if($zxinfo==false){
  708. return error_show(1003,"未找到信息数据");
  709. }
  710. if($zxinfo['status']!=1){
  711. return error_show(1004,"任务未进行");
  712. }
  713. $zx = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
  714. if($zx==false){
  715. return error_show(1003,"未找咨询信息数据");
  716. }
  717. $pname = isset($this->post['pname'])&&$this->post['pname']!=""? trim($this->post['pname']):"";
  718. if($pname==""){
  719. return error_show(1002,"参数pname不能为空");
  720. }
  721. $brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):"";
  722. // if($brandid==""){
  723. // return error_show(1002,"参数brandid不能为空");
  724. // }
  725. $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? trim($this->post['cat_id']):"";
  726. if($cat_id==""){
  727. return error_show(1002,"参数cat_id不能为空");
  728. }
  729. $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
  730. if($specin==""){
  731. return error_show(1003,"参数specinfo不能为空");
  732. }
  733. $specinfo=[];
  734. foreach ($specin as $v){
  735. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  736. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  737. $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
  738. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
  739. $specinfo[]=$v;
  740. }
  741. // $model = isset($this->post['model'])&&$this->post['model']!=""? trim($this->post['model']):"";
  742. // //$unit = isset($this->post['model'])&&$this->post['model']!=""? trim($this->post['model']):"";
  743. // $material = isset($this->post['material'])&&$this->post['material']!=""? trim($this->post['material']):"";
  744. // $color = isset($this->post['color'])&&$this->post['color']!=""? trim($this->post['color']):"";
  745. $unit_id = isset($this->post['unit_id'])&&$this->post['unit_id']!=""? intval($this->post['unit_id']):"";
  746. $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""? trim($this->post['cost_desc']):"";
  747. $work_day = isset($this->post['work_day'])&&$this->post['work_day']!=""? intval($this->post['work_day']):"";
  748. $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!=""? intval($this->post['delivery_day']):"";
  749. $good_img = isset($this->post['good_img'])&&$this->post['good_img']!=""? trim($this->post['good_img']):"";
  750. $expire_day = isset($this->post['expire_day'])&&$this->post['expire_day']!=""? intval($this->post['expire_day'])
  751. :"";
  752. $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!=""? trim($this->post['origin_place']):"";
  753. $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
  754. $pay_way = isset($this->post['pay_way'])&&$this->post['pay_way']!=""? intval($this->post['pay_way']):"";
  755. $tax = isset($this->post['tax'])&&$this->post['tax']!=""? trim($this->post['tax']):"";
  756. $send_way = isset($this->post['send_way'])&&$this->post['send_way']!=""? intval($this->post['send_way']):"";
  757. $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!=""? intval($this->post['metal_id']):"";
  758. $is_gold_price = isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!=""? intval($this->post['is_gold_price']):"";
  759. $config = isset($this->post['config'])&&$this->post['config']!=""? $this->post['config']:"";
  760. $other_config = isset($this->post['other_config'])&&$this->post['other_config']!=""? $this->post['other_config']:"";
  761. $weight = isset($this->post['weight'])&&$this->post['weight']!=""? floatval($this->post['weight']):"";
  762. $good_weight = isset($this->post['good_weight'])&&$this->post['good_weight']!=""? floatval($this->post['good_weight']):"";
  763. $demo_fee = isset($this->post['demo_fee'])&&$this->post['demo_fee']!=""? floatval($this->post['demo_fee']):"";
  764. $delivery_fee = isset($this->post['delivery_fee'])&&$this->post['delivery_fee']!=""? floatval($this->post['delivery_fee']):"";
  765. $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!=""? floatval($this->post['open_fee']):"";
  766. $pakge_fee = isset($this->post['pakge_fee'])&&$this->post['pakge_fee']!=""? floatval($this->post['pakge_fee']):"";
  767. $nake_fee = isset($this->post['nake_fee'])&&$this->post['nake_fee']!=""? floatval($this->post['nake_fee']):"";
  768. $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!=""? floatval($this->post['mark_fee']):"";
  769. $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!=""? floatval($this->post['cert_fee']):"";
  770. $cost_fee = isset($this->post['cost_fee'])&&$this->post['cost_fee']!=""? floatval($this->post['cost_fee']):"";
  771. $total_fee = isset($this->post['total_fee'])&&$this->post['total_fee']!=""? floatval($this->post['total_fee']):"";
  772. $is_diff = isset($this->post['is_diff'])&&$this->post['is_diff']!==""? intval($this->post['is_diff']):"";
  773. $supply_area = isset($this->post['supply_area'])&&$this->post['supply_area']!==""? intval($this->post['supply_area']):"";
  774. $remark = isset($this->post['remark'])&&$this->post['remark']!=""? trim($this->post['remark']):"";
  775. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  776. if($token==''){
  777. return error_show(1002,"参数token不能为空");
  778. }
  779. $user =GetUserInfo($token);
  780. if(empty($user)||$user['code']!=0){
  781. return error_show(1005,"用户数据不存在");
  782. }
  783. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  784. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  785. $bidNo=makeNo("BD");
  786. $spucode=makeNo("SPU");
  787. $catinfo = Db::name("cat")->where(["id"=>$cat_id])->find();
  788. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:1;
  789. if($is_gold_price=1){
  790. $gold = Db::name("gold_price1")->where(["type"=>$metal_id,"is_del"=>0,"status"=>1])->order("addtime desc")
  791. ->find();
  792. $total_fee = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee*
  793. $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  794. $saleprice = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee/(1-$budget)*
  795. $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  796. }else{
  797. $saleprice = $open_fee/$zxinfo['num'] +
  798. $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee/(1-$budget);
  799. $total_fee = $open_fee/$zxinfo['num'] +
  800. $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  801. }
  802. $data=[
  803. "bidNo"=>$bidNo,
  804. "infoNo"=>$infoNo,
  805. "zxNo"=>$zxinfo['zxNo'],
  806. "spuCode"=>$spucode,
  807. "good_name"=>$pname,
  808. "brand_id"=>$brandid,
  809. "cat_id"=>$cat_id,
  810. "specinfo"=>json_encode($specinfo),
  811. "unit_id"=>$unit_id,
  812. "cost_desc"=>$cost_desc,
  813. "work_day"=>$work_day,
  814. "delivery_day"=>$delivery_day,
  815. "good_img"=>$good_img,
  816. "expire_day"=>$expire_day,
  817. "origin_place"=>$origin_place,
  818. "supplierNo"=>$supplierNo,
  819. "pay_way"=>$pay_way,
  820. "tax"=>$tax,
  821. "send_way"=>$send_way,
  822. "metal_id"=>$metal_id,
  823. "is_gold_price"=>$is_gold_price,
  824. "config"=>$config,
  825. "other_config"=>$other_config,
  826. "weight"=>$weight,
  827. "good_weight"=>$good_weight,
  828. "is_diff"=>$is_diff,
  829. "demo_fee"=>$demo_fee,
  830. "delivery_fee"=>$delivery_fee,
  831. "open_fee"=>$open_fee,
  832. "pakge_fee"=>$pakge_fee,
  833. "nake_fee"=>$nake_fee,
  834. "mark_fee"=>$mark_fee,
  835. "cert_fee"=>$cert_fee,
  836. "cost_fee"=>$cost_fee,
  837. "total_fee"=>$total_fee,
  838. "supply_area"=>$supply_area,
  839. "remark"=>$remark,
  840. "sale_price"=>$saleprice,
  841. "createrid"=>$createrid,
  842. "creater"=>$creater,
  843. "status"=>$zxinfo['status']==1 ?1 :2,
  844. "is_del"=>0,
  845. "addtime"=>date("Y-m-d H:i:s"),
  846. "updatetime"=>date("Y-m-d H:i:s")
  847. ];
  848. Db::startTrans();
  849. try{
  850. $insert= Db::name("consult_bids")->insert($data);
  851. if($insert){
  852. // $data=[
  853. // "spuCode"=>$spucode,
  854. // "good_name"=>$pname,
  855. // "brand_id"=>$brandid,
  856. // "good_unit"=>$unit_id,
  857. // "good_type"=>0,
  858. // "moq"=>1,
  859. // "customized"=>$work_day,
  860. // "tax"=>$tax,
  861. // "supplierNo"=>$supplierNo,
  862. // "is_auth"=>0,
  863. // "craft_desc"=>$cost_desc,
  864. // "good_remark"=>$remark,
  865. // "good_img"=>$good_img,
  866. // "good_thumb_img"=>"",
  867. // "good_info_img"=>"",
  868. // "status"=>1,
  869. // "is_del"=>0,
  870. // "createrid"=>$createrid,
  871. // "creater"=>$creater,
  872. // "addtime"=>date("Y-m-d H:i:s"),
  873. // "updatetime"=>date("Y-m-d H:i:s")
  874. // ];
  875. // $good = Db::name("good_zixun")->insert($data);
  876. if($zx['is_project']==1 && $zx['projectNo']!="" && $zxinfo['pgNo']!=""){
  877. $projectinfo =Db::name("project_info")->where(["pgNo"=>$zxinfo["pgNo"],"projectNo"=>$zx['projectNo'],"is_del"=>0])->find();
  878. if($projectinfo==false){
  879. Db::rollback();
  880. return error_show(1006,"未找到项目信息");
  881. }
  882. $temp=[];
  883. $temp['spuCode']=$spucode;
  884. $temp['skuCode']="";
  885. $temp['pgNo']=$zxinfo['pgNo'];
  886. $temp['projectNo']=$zx['projectNo'];
  887. $temp['good_name']=$pname;
  888. $temp['good_type']=$projectinfo['good_type'];
  889. $temp['data_source']=2;
  890. $temp['cat_id']=$cat_id;
  891. $temp['budget_price']=$projectinfo['budget_price'];
  892. $temp['sale_price']=$saleprice;
  893. $temp['origin_price']=$total_fee;
  894. $temp['num']=$zxinfo['num'];
  895. $temp['status']=0;
  896. $temp['is_del']=0;
  897. $temp['creater']=$creater;
  898. $temp['createrid']=$createrid;
  899. $temp['addtime']=date("Y-m-d H:i:s");
  900. $temp['updatetime']=date("Y-m-d H:i:s");
  901. $nu = Db::name("project_feedback")->insert($temp);
  902. if($nu==false){
  903. Db::rollback();
  904. return error_show(1006,"项目反馈失败");
  905. }else{
  906. $projectinfo['status']=2;
  907. $projectinfo['updatetime']=date("Y-m-d H:i:s");
  908. $up = Db::name("project_info")->save($projectinfo);
  909. if($up){
  910. $count = Db::name("project_info")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])
  911. ->count();
  912. if($count==0){
  913. $proc =Db::name("project")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])->save
  914. (["status"=>2,"updatetime"=>date("Y-m-d H:i:s")]);
  915. if($proc==false){
  916. Db::rollback();
  917. return error_show(1006,"项目反馈失败");
  918. }
  919. }
  920. }
  921. }
  922. }
  923. Db::commit();
  924. return app_show(0,"反馈成功",["bidNo"=>$bidNo]);
  925. }else{
  926. Db::rollback();
  927. return error_show(1006,"反馈失败");
  928. }
  929. }catch (\Exception $e){
  930. Db::rollback();
  931. return error_show(1006,$e->getMessage());
  932. }
  933. }
  934. public function feadinfo(){
  935. $bidNo =isset($this->post['bidNo'])&& $this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  936. if($bidNo==""){
  937. return error_show(1004,"参数bidNo不能为空");
  938. }
  939. $info =Db::name("consult_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
  940. if($info==false){
  941. return error_show(1004,"未找到商品数据");
  942. }
  943. $unit =Db::name("unit")->where(["id"=>$info['unit_id']])->find();
  944. $info['unit'] = isset($unit['unit'])?$unit['unit']:'';
  945. $info['cat_info'] = made($info['cat_id'],[]);
  946. $supplier = Db::name("supplier")->where(["code"=>$info['supplierNo']])->find();
  947. $info['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  948. if($info['brand_id']!=0){
  949. $brand=Db::name("brand")->where(["id"=>$info['brand_id']])->find();
  950. $info["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  951. }else{
  952. $info["brand_name"]="";
  953. $info["brand_id"]="";
  954. }
  955. $catinfo = Db::name("cat")->where(["id"=>$info['cat_id']])->find();
  956. $bidinfo = Db::name("consult_info")->where(["infoNo"=>$info["infoNo"]])->find();
  957. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:100;
  958. $god=[
  959. "metal_id"=>$info['metal_id'],
  960. "weight"=>$info["weight"],
  961. "demo_fee"=>$info["demo_fee"],
  962. "delivery_fee"=>$info["delivery_fee"],
  963. "open_fee"=>$info["open_fee"],
  964. "packing_fee"=>$info["pakge_fee"],
  965. "mark_fee"=>$info["mark_fee"],
  966. "nake_fee"=>$info["nake_fee"],
  967. "cert_fee"=>$info["cert_fee"],
  968. "cost_fee"=>$info["cost_fee"],
  969. "num"=>$bidinfo["num"],
  970. ];
  971. if($info['is_gold_price']==1){
  972. $price = GoldPrice($god, $budget/100);
  973. }else{
  974. $price = GoodPrice($god, $budget/100);
  975. }
  976. $info['specinfo'] = json_decode($info['specinfo'],true);
  977. $info['sale_price'] =round($price,2);
  978. $info['metal_name']=isset($info['metal_id'])&& $info['metal_id']!=0?$this->noble[$info['metal_id']]:"";
  979. $bargain =Db::name("bargain_order")->where(['bidsNo'=>$bidNo,"is_del"=>0])->find();
  980. $info['bargain'] =$bargain;
  981. return app_show(0,"获取成功",$info);
  982. }
  983. public function feededit(){
  984. $bidNo= isset($this->post['bidNo'])&&$this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  985. if($bidNo==""){
  986. return error_show(1002,"参数bidNo不能为空");
  987. }
  988. $bidinfo = Db::name("consult_bids")->where(["bidNo"=>$bidNo,"is_del"=>0])->find();
  989. if($bidinfo==false){
  990. return error_show(1003,"未找到信息数据");
  991. }
  992. if($bidinfo['status']>=5){
  993. return error_show(1004,"咨询单已确认无法修改");
  994. }
  995. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$bidinfo['infoNo'],"is_del"=>0])->find();
  996. if($zxinfo==false){
  997. return error_show(1003,"未找到信息数据");
  998. }
  999. $zx = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
  1000. if($zx==false){
  1001. return error_show(1003,"未找咨询信息数据");
  1002. }
  1003. $pname = isset($this->post['pname'])&&$this->post['pname']!=""? trim($this->post['pname']):"";
  1004. if($pname==""){
  1005. return error_show(1002,"参数pname不能为空");
  1006. }
  1007. $brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):"";
  1008. // if($brandid==""){
  1009. // return error_show(1002,"参数brandid不能为空");
  1010. // }
  1011. $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? trim($this->post['cat_id']):"";
  1012. if($cat_id==""){
  1013. return error_show(1002,"参数cat_id不能为空");
  1014. }
  1015. $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
  1016. if($specin==""){
  1017. return error_show(1003,"参数specinfo不能为空");
  1018. }
  1019. $specinfo=[];
  1020. foreach ($specin as $v){
  1021. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  1022. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  1023. $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
  1024. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
  1025. $specinfo[]=$v;
  1026. }
  1027. $unit_id = isset($this->post['unit_id'])&&$this->post['unit_id']!=""? intval($this->post['unit_id']):"";
  1028. $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""? trim($this->post['cost_desc']):"";
  1029. $work_day = isset($this->post['work_day'])&&$this->post['work_day']!=""? intval($this->post['work_day']):"";
  1030. $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!=""? intval($this->post['delivery_day']):"";
  1031. $good_img = isset($this->post['good_img'])&&$this->post['good_img']!=""? trim($this->post['good_img']):"";
  1032. $expire_day = isset($this->post['expire_day'])&&$this->post['expire_day']!=""? intval($this->post['expire_day'])
  1033. :"";
  1034. $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!=""? trim($this->post['origin_place']):"";
  1035. $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
  1036. $pay_way = isset($this->post['pay_way'])&&$this->post['pay_way']!=""? intval($this->post['pay_way']):"";
  1037. $tax = isset($this->post['tax'])&&$this->post['tax']!=""? trim($this->post['tax']):"";
  1038. $send_way = isset($this->post['send_way'])&&$this->post['send_way']!=""? intval($this->post['send_way']):"";
  1039. $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!=""? intval($this->post['metal_id']):"";
  1040. $is_gold_price = isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!=""? intval($this->post['is_gold_price']):"";
  1041. $config = isset($this->post['config'])&&$this->post['config']!=""? $this->post['config']:"";
  1042. $other_config = isset($this->post['other_config'])&&$this->post['other_config']!=""? $this->post['other_config']:"";
  1043. $weight = isset($this->post['weight'])&&$this->post['weight']!=""? floatval($this->post['weight']):"";
  1044. $demo_fee = isset($this->post['demo_fee'])&&$this->post['demo_fee']!=""? floatval($this->post['demo_fee']):"";
  1045. $delivery_fee = isset($this->post['delivery_fee'])&&$this->post['delivery_fee']!=""? floatval($this->post['delivery_fee']):"";
  1046. $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!=""? floatval($this->post['open_fee']):"";
  1047. $pakge_fee = isset($this->post['pakge_fee'])&&$this->post['pakge_fee']!=""? floatval($this->post['pakge_fee']):"";
  1048. $nake_fee = isset($this->post['nake_fee'])&&$this->post['nake_fee']!=""? floatval($this->post['nake_fee']):"";
  1049. $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!=""? floatval($this->post['mark_fee']):"";
  1050. $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!=""? floatval($this->post['cert_fee']):"";
  1051. $cost_fee = isset($this->post['cost_fee'])&&$this->post['cost_fee']!=""? floatval($this->post['cost_fee']):"";
  1052. $total_fee = isset($this->post['total_fee'])&&$this->post['total_fee']!=""? floatval($this->post['total_fee']):"";
  1053. $is_diff = isset($this->post['is_diff'])&&$this->post['is_diff']!==""? intval($this->post['is_diff']):"";
  1054. $supply_area = isset($this->post['supply_area'])&&$this->post['supply_area']!==""? intval($this->post['supply_area']):"";
  1055. $remark = isset($this->post['remark'])&&$this->post['remark']!=""? trim($this->post['remark']):"";
  1056. $catinfo = Db::name("cat")->where(["id"=>$cat_id])->find();
  1057. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:1;
  1058. if($is_gold_price=1){
  1059. $gold = Db::name("gold_price1")->where(["type"=>$metal_id,"is_del"=>0,"status"=>1])->order("addtime desc")
  1060. ->find();
  1061. $total_fee = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee*
  1062. $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  1063. $saleprice = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee/(1-$budget)*
  1064. $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  1065. }else{
  1066. $saleprice = $open_fee/$zxinfo['num'] +
  1067. $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee/(1-$budget);
  1068. $total_fee = $open_fee/$zxinfo['num'] +
  1069. $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  1070. }
  1071. Db::startTrans();
  1072. try{
  1073. $data=[
  1074. "good_name"=>$pname,
  1075. "brand_id"=>$brandid,
  1076. "cat_id"=>$cat_id,
  1077. "specinfo"=>json_encode($specinfo),
  1078. // "material"=>$material,
  1079. "unit_id"=>$unit_id,
  1080. "cost_desc"=>$cost_desc,
  1081. "work_day"=>$work_day,
  1082. "delivery_day"=>$delivery_day,
  1083. "good_img"=>$good_img,
  1084. "expire_day"=>$expire_day,
  1085. "origin_place"=>$origin_place,
  1086. "supplierNo"=>$supplierNo,
  1087. "pay_way"=>$pay_way,
  1088. "tax"=>$tax,
  1089. "send_way"=>$send_way,
  1090. "metal_id"=>$metal_id,
  1091. "is_gold_price"=>$is_gold_price,
  1092. "config"=>$config,
  1093. "other_config"=>$other_config,
  1094. "weight"=>$weight,
  1095. "is_diff"=>$is_diff,
  1096. "demo_fee"=>$demo_fee,
  1097. "delivery_fee"=>$delivery_fee,
  1098. "open_fee"=>$open_fee,
  1099. "pakge_fee"=>$pakge_fee,
  1100. "nake_fee"=>$nake_fee,
  1101. "mark_fee"=>$mark_fee,
  1102. "cert_fee"=>$cert_fee,
  1103. "cost_fee"=>$cost_fee,
  1104. "total_fee"=>$total_fee,
  1105. "sale_price"=>$saleprice,
  1106. "supply_area"=>$supply_area,
  1107. "remark"=>$remark,
  1108. "updatetime"=>date("Y-m-d H:i:s")
  1109. ];
  1110. $insert= Db::name("consult_bids")->where($bidinfo)->save($data);
  1111. if($insert){
  1112. if($zx['is_project']==1 && $zx['projectNo']!="" && $zxinfo['pgNo']!=""){
  1113. $projectinfo =Db::name("project_info")->where(["pgNo"=>$zxinfo["pgNo"],"projectNo"=>$zx['projectNo'],"is_del"=>0])->find();
  1114. if($projectinfo==false){
  1115. Db::rollback();
  1116. return error_show(1006,"未找到项目信息");
  1117. }
  1118. $feed = Db::name("project_feedback")->where(["pgNo"=>$zxinfo["pgNo"],
  1119. "projectNo"=>$zx['projectNo'],"spuCode"=>$bidinfo['spuCode'],"is_del"=>0])->find();
  1120. if($feed==false){
  1121. Db::rollback();
  1122. return error_show(1006,"未找到项目反馈信息");
  1123. }
  1124. $feed['good_name']=$pname;
  1125. $feed['good_type']=$projectinfo['good_type'];
  1126. $feed['cat_id']=$cat_id;
  1127. $feed['sale_price']=$saleprice;
  1128. $feed['origin_price']=$total_fee;
  1129. $temp['updatetime']=date("Y-m-d H:i:s");
  1130. $nu = Db::name("project_feedback")->save($feed);
  1131. if($nu==false){
  1132. Db::rollback();
  1133. return error_show(1006,"项目反馈失败");
  1134. }else{
  1135. $projectinfo['status']=2;
  1136. $projectinfo['updatetime']=date("Y-m-d H:i:s");
  1137. $up = Db::name("project_info")->save($projectinfo);
  1138. if($up){
  1139. $count = Db::name("project_info")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])
  1140. ->count();
  1141. if($count==0){
  1142. $proc =Db::name("project")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])->save
  1143. (["status"=>2,"updatetime"=>date("Y-m-d H:i:s")]);
  1144. if($proc==false){
  1145. Db::rollback();
  1146. return error_show(1006,"项目反馈失败");
  1147. }
  1148. }
  1149. }
  1150. }
  1151. }
  1152. Db::commit();
  1153. return app_show(0,"编辑成功");
  1154. }else{
  1155. Db::rollback();
  1156. return error_show(1004,"编辑失败");
  1157. }
  1158. }catch (\Exception $e){
  1159. Db::rollback();
  1160. return error_show(1004,$e->getMessage());
  1161. }
  1162. }
  1163. public function bargain_add(){
  1164. $bidNo = isset($this->post['bidNo'])&& $this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  1165. if($bidNo===""){
  1166. return error_show(1004,"参数bidNo不能为空");
  1167. }
  1168. $info =Db::name("consult_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
  1169. if($info==false){
  1170. return error_show(1004,"未找到商品数据");
  1171. }
  1172. $bargain_price = isset($this->post['bargain_price'])&& $this->post['bargain_price']!=""?floatval($this->post['bargain_price']):"";
  1173. if($bargain_price===""){
  1174. return error_show(1004,"参数bargain_price不能为空");
  1175. }
  1176. $bargain_reason = isset($this->post['bargain_reason'])&& $this->post['bargain_reason']!=""?trim($this->post['bargain_reason']):"";
  1177. if($bargain_reason===""){
  1178. return error_show(1004,"参数bargain_reason不能为空");
  1179. }
  1180. $infos =Db::name("consult_info")->where(['infoNo'=>$info['infoNo'],"is_del"=>0])->find();
  1181. if($infos==false){
  1182. return error_show(1004,"未找到商品数据");
  1183. }
  1184. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1185. if($token==''){
  1186. return error_show(1005,"参数token不能为空");
  1187. }
  1188. $user =GetUserInfo($token);
  1189. if(empty($user)||$user['code']!=0){
  1190. return error_show(1002,"用户数据不存在");
  1191. }
  1192. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1193. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1194. $bargainNo =makeNo("BA");
  1195. Db::startTrans();//::todo 金价 毛利计算
  1196. try{
  1197. $data=[
  1198. "bidsNo"=>$bidNo,
  1199. "infoNo"=>$info['infoNo'],
  1200. "zxNo"=>$info['zxNo'],
  1201. "bargainNo"=>$bargainNo,
  1202. "bargain_type"=>1,
  1203. "bargain_reason"=>$bargain_reason,
  1204. "sale_price"=>$info['sale_price'],
  1205. "cost_before_price"=>$info['cost_fee'],
  1206. "cost_after_price"=>$info['cost_fee'],
  1207. "before_rate"=>$info['cost_fee'],
  1208. "after_rate"=>$info['cost_fee'],
  1209. "after_price"=>$bargain_price,
  1210. "exam_info"=>"",
  1211. "status"=>1,
  1212. "is_del"=>0,
  1213. "creater"=>$creater,
  1214. "createrid"=>$createrid,
  1215. "addtime"=>date("Y-m-d H:i:s"),
  1216. "updatetime"=>date("Y-m-d H:i:s")
  1217. ];
  1218. $int = Db::name("bargain_order")->insert($data);
  1219. if($int){
  1220. $info['status']=3;
  1221. $info['updatetime']=date("Y-m-d H:i:s");
  1222. $up =Db::name("consult_bids")->save($info);
  1223. if($up){
  1224. Db::commit();
  1225. return app_show(0,"议价单生成成功",["bargainNo"=>$bargainNo]);
  1226. }
  1227. }
  1228. }catch (\Exception $e){
  1229. Db::rollback();
  1230. return error_show(1004,$e->getMessage());
  1231. }
  1232. }
  1233. public function bargain_status(){
  1234. $bargainNo = isset($this->post['bargainNo'])&& $this->post['bargainNo']!=""?trim($this->post['bargainNo']):"";
  1235. if($bargainNo===""){
  1236. return error_show(1004,"参数bargainNo不能为空");
  1237. }
  1238. $info =Db::name("bargain_order")->where(['bargainNo'=>$bargainNo,"is_del"=>0])->find();
  1239. if($info==false){
  1240. return error_show(1004,"未找到议价数据");
  1241. }
  1242. $bids=Db::name("consult_bids")->where(["bidNo"=>$info["bidsNo"],"is_del"=>0])->find();
  1243. if($bids==false){
  1244. return error_show(1004,"未找到商品数据");
  1245. }
  1246. $status = isset($this->post['status'])&& $this->post['status']!=='' ? intval($this->post['status']):"";
  1247. if($status==''){
  1248. return error_show(1005,"参数status不能为空");
  1249. }
  1250. $remark = isset($this->post['remark'])&& $this->post['remark']!=""?trim($this->post['remark']):"";
  1251. if($remark==""){
  1252. return error_show(1004,"参数remark不能为空");
  1253. }
  1254. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1255. if($token==''){
  1256. return error_show(1005,"参数token不能为空");
  1257. }
  1258. $user =GetUserInfo($token);
  1259. if(empty($user)||$user['code']!=0){
  1260. return error_show(1002,"用户数据不存在");
  1261. }
  1262. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1263. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1264. Db::startTrans();
  1265. try{
  1266. $examinfo = isset($info['exam_info'])&&$info['exam_info']!="" ? json_decode($info['exam_info'],true):[];
  1267. $examinfo[]=["status"=>$status,"remark"=>$remark,"createrid"=>$createrid,"creater"=>$creater];
  1268. $info['status'] =$status;
  1269. $info['remark'] =$remark;
  1270. $info['exam_info']=json_encode($examinfo) ;
  1271. $info['updatetime'] =date("Y-m-d H:i:s");
  1272. $up =Db::name("bargain_order")->save($info);
  1273. if($up){
  1274. if($status==4){
  1275. $bids['status']=4;
  1276. $bids['sale_price']=$info['after_price'];
  1277. $bids['updatetime']=date("Y-m-d H:i:s");
  1278. $up =Db::name("consult_bids")->save($bids);
  1279. if($up==false){
  1280. Db::rollback();
  1281. return error_show(1004,"数据更新失败");
  1282. }
  1283. }
  1284. if($status==5||$status==6||$status==7){
  1285. $bids['status']=4;
  1286. $bids['updatetime']=date("Y-m-d H:i:s");
  1287. $up =Db::name("consult_bids")->save($bids);
  1288. if($up==false){
  1289. Db::rollback();
  1290. return error_show(1004,"数据更新失败");
  1291. }
  1292. }
  1293. Db::commit();
  1294. return app_show(0,"更新成功");
  1295. }
  1296. }catch (\Exception $e){
  1297. Db::rollback();
  1298. return error_show(1004,$e->getMessage());
  1299. }
  1300. }
  1301. public function bargain_info(){
  1302. $bargainNo = isset($this->post['bargainNo'])&& $this->post['bargainNo']!=""?trim($this->post['bargainNo']):"";
  1303. if($bargainNo===""){
  1304. return error_show(1004,"参数bargainNo不能为空");
  1305. }
  1306. $info =Db::name("bargain_order")->where(['bargainNo'=>$bargainNo,"is_del"=>0])->find();
  1307. if($info==false){
  1308. return error_show(1004,"未找到议价数据");
  1309. }
  1310. $bidinfos = Db::name("consult_bids")->where([["bidNo","=",$info['bidsNo']],["is_del","=",0]])->find();
  1311. if($bidinfos==false){
  1312. return error_show(1004,"未找到商品数据");
  1313. }
  1314. $consultinfos = Db::name("consult_info")->where([["infoNo","=",$bidinfos['infoNo']],["is_del","=",0]])
  1315. ->find();
  1316. if($consultinfos==false){
  1317. return error_show(1004,"未找到咨询商品数据");
  1318. }
  1319. $info['spuCode'] = isset($bidinfos['spuCode'])?$bidinfos['spuCode']:"";
  1320. $info['good_name'] = isset($bidinfos['good_name'])?$bidinfos['good_name']:"";
  1321. $info['good_img'] = isset($bidinfos['good_img'])?$bidinfos['good_img']:"";
  1322. $info['brand_id'] = isset($bidinfos['brand_id'])?$bidinfos['brand_id']:"";
  1323. $info['good_num'] = isset($consultinfos['num'])?$consultinfos['num']:"";
  1324. $info['exam_info'] = isset($info['exam_info'])&&$info['exam_info']!=""?json_encode($info['exam_info']):"";
  1325. if($bidinfos['brand_id']!=0){
  1326. $info['brand_id'] = $bidinfos['brand_id'];
  1327. $brand=Db::name("brand")->where(["id"=>$bidinfos['brand_id']])->find();
  1328. $info["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1329. }else{
  1330. $info["brand_name"]="";
  1331. $info["brand_id"]="";
  1332. }
  1333. $catinfo = Db::name("cat")->where(["id"=>$bidinfos['cat_id']])->find();
  1334. $info['can']= isset($bidinfos['cat_id']) && $bidinfos['cat_id'] !=0 ? made($bidinfos['cat_id']):[];
  1335. $unit =Db::name("unit")->where(["id"=>$bidinfos['unit_id']])->find();
  1336. $info['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1337. $bidinfoe = Db::name("consult_info")->where(["infoNo"=>$info["infoNo"]])->find();
  1338. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:100;
  1339. $info['budget'] =$budget;
  1340. $god=[
  1341. "metal_id"=>$bidinfos['metal_id'],
  1342. "weight"=>$bidinfos["weight"],
  1343. "demo_fee"=>$bidinfos["demo_fee"],
  1344. "delivery_fee"=>$bidinfos["delivery_fee"],
  1345. "open_fee"=>$bidinfos["open_fee"],
  1346. "packing_fee"=>$bidinfos["pakge_fee"],
  1347. "mark_fee"=>$bidinfos["mark_fee"],
  1348. "nake_fee"=>$bidinfos["nake_fee"],
  1349. "cert_fee"=>$bidinfos["cert_fee"],
  1350. "cost_fee"=>$bidinfos["cost_fee"],
  1351. "num"=>$bidinfoe["num"],
  1352. ];
  1353. $info['gold_price']=0;
  1354. if($bidinfos['is_gold_price']==1 &&$bidinfos['metal_id']>0){
  1355. $gold = Db::name("gold_price1")->where(["type"=>$bidinfos["metal_id"],"is_del"=>0,"status"=>1])->order("addtime desc")
  1356. ->find();
  1357. $info['gold_price'] =$gold['price'];
  1358. }
  1359. $info['cost_desc'] =$bidinfos['cost_desc'];
  1360. $info['work_day'] =$bidinfos['work_day'];
  1361. $info['delivery_day'] =$bidinfos['delivery_day'];
  1362. $info['expire_day'] =$bidinfos['expire_day'];
  1363. $info['origin_place'] =$bidinfos['origin_place'];
  1364. $info['origin_addr'] ="";
  1365. if($bidinfos['origin_place']!=''){
  1366. $code = explode(",",$bidinfos['origin_place']);
  1367. $temp=[];
  1368. $temp['provice_code']=isset($code[0])?$code[0]:"";
  1369. $temp['city_code']=isset($code[1])?$code[1]:"";
  1370. $temp['area_code']=isset($code[2])?$code[2]:"";
  1371. $addr= GetAddr(json_encode($temp));
  1372. $info['origin_addr'] = $addr;
  1373. }
  1374. $info['supplierNo'] =$bidinfos['supplierNo'];
  1375. $supplier = Db::name("supplier")->where(["code"=>$info['supplierNo']])->find();
  1376. $info['supplier_name'] = isset($supplier['name'])?$supplier['name']:"";
  1377. $info['pay_way'] =$bidinfos['pay_way'];
  1378. $info['tax'] =$bidinfos['tax'];
  1379. $info['send_way'] =$bidinfos['send_way'];
  1380. $info['metal_id'] =$bidinfos['metal_id'];
  1381. $info['is_gold_price'] =$bidinfos['is_gold_price'];
  1382. $info['config'] =$bidinfos['config'];
  1383. $info['other_config'] =$bidinfos['other_config'];
  1384. $info['weight'] =$bidinfos['weight'];
  1385. $info['is_diff'] =$bidinfos['is_diff'];
  1386. $info['demo_fee'] =$bidinfos['demo_fee'];
  1387. $info['delivery_fee'] =$bidinfos['delivery_fee'];
  1388. $info['open_fee'] =$bidinfos['open_fee'];
  1389. $info['pakge_fee'] =$bidinfos['pakge_fee'];
  1390. $info['nake_fee'] =$bidinfos['nake_fee'];
  1391. $info['mark_fee'] =$bidinfos['mark_fee'];
  1392. $info['cert_fee'] =$bidinfos['cert_fee'];
  1393. $info['cost_fee'] =$bidinfos['cost_fee'];
  1394. $info['total_fee'] =$bidinfos['total_fee'];
  1395. $info['supply_area'] =$bidinfos['supply_area'];
  1396. $info['remark'] =$bidinfos['remark'];
  1397. $info['is_addrs'] =$consultinfos['is_addrs'];
  1398. $info['is_custom'] =$consultinfos['is_custom'];
  1399. $info['metal_name']=isset($bidinfos['metal_id'])&& $bidinfos['metal_id']!=0?$this->noble[$bidinfos['metal_id']]:"";
  1400. $info['sale_price'] =round($bidinfos['sale_price'],2);
  1401. $info['specinfo'] = isset($bidinfos['specinfo'])&&$bidinfos['specinfo']!=""?json_decode($bidinfos['specinfo'],true):[];
  1402. return app_show(0,"获取成功",$info);
  1403. }
  1404. public function bidlist(){
  1405. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  1406. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  1407. $where=[['is_del',"=",0]];
  1408. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1409. if ($zxNo !== "") {
  1410. $where[] = ['zxNo','=',$zxNo];
  1411. }
  1412. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  1413. if ($infoNo !== "") {
  1414. $where[] = ['infoNo','=',$infoNo];
  1415. }
  1416. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
  1417. if ($bidNo !== "") {
  1418. $where[] = ['bidNo','=',$bidNo];
  1419. }
  1420. $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
  1421. if ($pgNo !== "") {
  1422. $bidinfo = Db::name("consult_info")->where([["pgNo","=",$pgNo],["is_del","=",0]])->column("infoNo");
  1423. $where[] = ['infoNo','in',$bidinfo];
  1424. }
  1425. $bargain_status = isset($this->post['bargain_status']) && $this->post['bargain_status'] !== "" ? intval($this->post['bargain_status']) : "";
  1426. if ($bargain_status !== "") {
  1427. $bidinfo = Db::name("consult_info")->where([["bargain_status","=",$bargain_status],["is_del","=",0]])->column("infoNo");
  1428. $where[] = ['infoNo','in',$bidinfo];
  1429. }
  1430. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  1431. if ($projectNo !== "") {
  1432. $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column
  1433. ("zxNo");
  1434. $where[] = ['zxNo','in',$zxlist];
  1435. }
  1436. $count = Db::name('consult_bids')->where($where)->count();
  1437. $total = ceil($count / $size);
  1438. $page = $page >= $total ? $total : $page;
  1439. $list =Db::name('consult_bids')->where($where)->page($page,$size)->select();
  1440. $data=[];
  1441. foreach ($list as $value){
  1442. $catinfo = Db::name("cat")->where(["id"=>$value['cat_id']])->find();
  1443. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  1444. $unit =Db::name("unit")->where(["id"=>$value['unit_id']])->find();
  1445. $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1446. $supplier = Db::name("supplier")->where(["code"=>$value['supplierNo']])->find();
  1447. $value['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  1448. if($value['brand_id']!=0){
  1449. $brand=Db::name("brand")->where(["id"=>$value['brand_id']])->find();
  1450. $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1451. }else{
  1452. $value["brand_name"]="";
  1453. $value["brand_id"]="";
  1454. }
  1455. $bidinfo = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
  1456. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:100;
  1457. $god=[
  1458. "metal_id"=>$value['metal_id'],
  1459. "weight"=>$value["weight"],
  1460. "demo_fee"=>$value["demo_fee"],
  1461. "delivery_fee"=>$value["delivery_fee"],
  1462. "open_fee"=>$value["open_fee"],
  1463. "packing_fee"=>$value["pakge_fee"],
  1464. "mark_fee"=>$value["mark_fee"],
  1465. "nake_fee"=>$value["nake_fee"],
  1466. "cert_fee"=>$value["cert_fee"],
  1467. "cost_fee"=>$value["cost_fee"],
  1468. "num"=>$bidinfo["num"],
  1469. ];
  1470. if($value['is_gold_price']==1){
  1471. $price = GoldPrice($god, $budget/100);
  1472. }else{
  1473. $price = GoodPrice($god, $budget/100);
  1474. }
  1475. $value['specinfo'] = json_decode($value['specinfo'],true);
  1476. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  1477. $value['sale_price'] =round($price,2);
  1478. $value['bargain_status']=$bidinfo['bargain_status'];
  1479. $data[]=$value;
  1480. }
  1481. return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
  1482. }
  1483. public function feedlist(){
  1484. $where=[['is_del',"=",0]];
  1485. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1486. if ($zxNo !== "") {
  1487. $where[] = ['zxNo','=',$zxNo];
  1488. }
  1489. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  1490. if ($infoNo !== "") {
  1491. $where[] = ['infoNo','=',$infoNo];
  1492. }
  1493. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
  1494. if ($bidNo !== "") {
  1495. $where[] = ['bidNo','=',$bidNo];
  1496. }
  1497. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  1498. if ($projectNo !== "") {
  1499. $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column
  1500. ("zxNo");
  1501. $where[] = ['zxNo','in',$zxlist];
  1502. }
  1503. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1504. if($token==''){
  1505. return error_show(102,"参数token不能为空");
  1506. }
  1507. $user =GetUserInfo($token);
  1508. if(empty($user)||$user['code']!=0){
  1509. return error_show(105,"用户数据不存在");
  1510. }
  1511. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1512. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1513. $where[] = ["createrid","=",$createrid];
  1514. $list =Db::name('consult_bids')->where($where)->select();
  1515. $data=[];
  1516. foreach ($list as $value){
  1517. $catinfo = Db::name("cat")->where(["id"=>$value['cat_id']])->find();
  1518. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  1519. $unit =Db::name("unit")->where(["id"=>$value['unit_id']])->find();
  1520. $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1521. $supplier = Db::name("supplier")->where(["code"=>$value['supplierNo']])->find();
  1522. $value['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  1523. if($value['brand_id']!=0){
  1524. $brand=Db::name("brand")->where(["id"=>$value['brand_id']])->find();
  1525. $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1526. }else{
  1527. $value["brand_name"]="";
  1528. $value["brand_id"]="";
  1529. }
  1530. $bidinfo = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
  1531. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:100;
  1532. $god=[
  1533. "metal_id"=>$value['metal_id'],
  1534. "weight"=>$value["weight"],
  1535. "demo_fee"=>$value["demo_fee"],
  1536. "delivery_fee"=>$value["delivery_fee"],
  1537. "open_fee"=>$value["open_fee"],
  1538. "packing_fee"=>$value["pakge_fee"],
  1539. "mark_fee"=>$value["mark_fee"],
  1540. "nake_fee"=>$value["nake_fee"],
  1541. "cert_fee"=>$value["cert_fee"],
  1542. "cost_fee"=>$value["cost_fee"],
  1543. "num"=>$bidinfo["num"],
  1544. ];
  1545. if($value['is_gold_price']==1){
  1546. $price = GoldPrice($god, $budget/100);
  1547. }else{
  1548. $price = GoodPrice($god, $budget/100);
  1549. }
  1550. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  1551. $value['sale_price'] =round($price,2);
  1552. $value['specinfo'] = json_decode($value['specinfo'],true);
  1553. $value['bargain_status']=$bidinfo['bargain_status'];
  1554. $data[]=$value;
  1555. }
  1556. return app_show(0,"获取成功",$data);
  1557. }
  1558. public function bragain_list(){
  1559. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  1560. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  1561. $where=[['is_del',"=",0]];
  1562. $bidsNo = isset($this->post['bidsNo'])&&$this->post['bidsNo']!=""?trim($this->post['bidsNo']):"";
  1563. if($bidsNo!=""){
  1564. $where[]=["bidsNo","=",$bidsNo];
  1565. }
  1566. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1567. if ($zxNo !== "") {
  1568. $where[] = ['zxNo','=',$zxNo];
  1569. }
  1570. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  1571. if ($infoNo !== "") {
  1572. $where[] = ['infoNo','=',$infoNo];
  1573. }
  1574. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  1575. if ($projectNo !== "") {
  1576. $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column
  1577. ("zxNo");
  1578. $where[] = ['zxNo','in',$zxlist];
  1579. }
  1580. $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
  1581. if ($pgNo !== "") {
  1582. $bidinfo = Db::name("consult_info")->where([["pgNo","=",$pgNo],["is_del","=",0]])->column("infoNo");
  1583. $where[] = ['infoNo','in',$bidinfo];
  1584. }
  1585. $count=Db::name("bargain_order")->where($where)->count();
  1586. $total = ceil($count / $size);
  1587. $page = $page >= $total ? $total : $page;
  1588. $list =Db::name('bargain_order')->where($where)->page($page,$size)->select();
  1589. $data=[];
  1590. foreach ($list as $value){
  1591. $bidinfos = Db::name("consult_bids")->where([["bidNo","=",$value['bidsNo']],["is_del","=",0]])->find();
  1592. $value['spuCode'] = isset($bidinfos['spuCode'])?$bidinfos['spuCode']:"";
  1593. $value['good_name'] = isset($bidinfos['good_name'])?$bidinfos['good_name']:"";
  1594. $value['good_img'] = isset($bidinfos['good_img'])?$bidinfos['good_img']:"";
  1595. $value['brand_id'] = isset($bidinfos['brand_id'])?$bidinfos['brand_id']:"";
  1596. if($bidinfos['brand_id']!=0){
  1597. $value['brand_id'] = $bidinfos['brand_id'];
  1598. $brand=Db::name("brand")->where(["id"=>$bidinfos['brand_id']])->find();
  1599. $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1600. }else{
  1601. $value["brand_name"]="";
  1602. $value["brand_id"]="";
  1603. }
  1604. $catinfo = Db::name("cat")->where(["id"=>$bidinfos['cat_id']])->find();
  1605. $value['can']= isset($bidinfos['cat_id']) && $bidinfos['cat_id'] !=0 ? made($bidinfos['cat_id']):[];
  1606. $unit =Db::name("unit")->where(["id"=>$bidinfos['unit_id']])->find();
  1607. $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1608. $bidinfoe = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
  1609. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:100;
  1610. $value['budget'] =$budget;
  1611. $god=[
  1612. "metal_id"=>$bidinfos['metal_id'],
  1613. "weight"=>$bidinfos["weight"],
  1614. "demo_fee"=>$bidinfos["demo_fee"],
  1615. "delivery_fee"=>$bidinfos["delivery_fee"],
  1616. "open_fee"=>$bidinfos["open_fee"],
  1617. "packing_fee"=>$bidinfos["pakge_fee"],
  1618. "mark_fee"=>$bidinfos["mark_fee"],
  1619. "nake_fee"=>$bidinfos["nake_fee"],
  1620. "cert_fee"=>$bidinfos["cert_fee"],
  1621. "cost_fee"=>$bidinfos["cost_fee"],
  1622. "num"=>$bidinfoe["num"],
  1623. ];
  1624. // if($bidinfos['is_gold_price']==1){
  1625. // $price = GoldPrice($god, $budget/100);
  1626. // }else{
  1627. // $price = GoodPrice($god, $budget/100);
  1628. // }
  1629. $value['metal_name']=isset($bidinfos['metal_id'])&& $bidinfos['metal_id']!=0?$this->noble[$bidinfos['metal_id']]:"";
  1630. $value['sale_price'] =round($bidinfos['sale_price'],2);
  1631. $value['specinfo'] = isset($bidinfos['specinfo'])&&$bidinfos['specinfo']!=""?json_decode($bidinfos['specinfo'],true):[];
  1632. $data[]=$value;
  1633. }
  1634. return app_show(0,"获取成功",["list"=>$data,"count"=>$count]);
  1635. }
  1636. public function crontablist(){
  1637. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  1638. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  1639. $where=[['a.is_del',"=",0],['b.is_del',"=",0]];
  1640. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1641. if ($zxNo !== "") {
  1642. $where[] = ['a.zxNo','=',$zxNo];
  1643. }
  1644. $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
  1645. if ($salesman !== "") {
  1646. //$where["salesman"] =Db::Raw("like '%$salesman%'");
  1647. $where[]= ["b.salesman",'like',"%$salesman%"];
  1648. }
  1649. $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : "";
  1650. if ($cpName !== "") {
  1651. //$where["cpName"]= Db::Raw("like '%$cpName%'");
  1652. $where[]= ["a.good_Name",'like',"%$cpName%"];
  1653. }
  1654. $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
  1655. if ($khNo !== "") {
  1656. // $where['khNo'] = $khNo;
  1657. $where[]= ["b.khNo",'like',"%$khNo%"];
  1658. }
  1659. $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
  1660. if ($start !="") {
  1661. //$where = ["zxtime"=>Db::raw(">= '{$start}'")];
  1662. $where[]= ["a.addtime",'>=',$start];
  1663. }
  1664. $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
  1665. if($end !=""){
  1666. $where[]= ["a.addtime",'<=',$end];
  1667. }
  1668. $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
  1669. if ($status !== "") {
  1670. $where[]= ["a.status",'=',$status];
  1671. }
  1672. $count = Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)
  1673. ->count();
  1674. $total = ceil($count / $size);
  1675. $page = $page >= $total ? $total : $page;
  1676. $list =Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)->page($page,$size)
  1677. ->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();
  1678. $data=[];
  1679. foreach ($list as $value){
  1680. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  1681. $brand = Db::name("brand")->where(['id'=>$value['brand_id']])->find();
  1682. $value['brand_name']= isset($brand['brand_name']) && $brand['brand_name']!='' ? $brand['brand_name']:"";
  1683. $value['khname']="";
  1684. $value['specinfo']=isset($value['specinfo'])&&$value['specinfo']!=""? json_decode($value['specinfo'],
  1685. true):[];
  1686. if($value['khNo']!==""){
  1687. $kh=Db::name("customer_info")->where(['companyNo'=>$value['khNo']])->find();
  1688. $value['khname']= isset($kh['companyName'])?$kh['companyName']:"";
  1689. }
  1690. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  1691. $data[]=$value;
  1692. }
  1693. return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
  1694. }
  1695. }