Consult.php 89 KB

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