Consult.php 108 KB

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