Consult.php 150 KB

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