Consult.php 131 KB

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