Consult.php 129 KB

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