Consult.php 149 KB

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