Consult.php 149 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749
  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 del(){
  122. $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) : "";
  123. $de = Db::name('consult')->where(['id'=>$id,'is_del'=>0])->find();
  124. if($de==false){
  125. return error_show(1002,'咨询单信息未找到');
  126. }
  127. $dell= Db::name('consult')->update(['id'=>$id,'is_del'=>1,'updatetime'=>date("Y-m-d H:i:s")]);
  128. if($dell){
  129. return error_show(0,"删除成功");
  130. }else
  131. return error_show(1002,"删除失败");
  132. }
  133. public function create(){
  134. $is_project= isset($this->post['is_project']) && $this->post['is_project'] !=="" ? intval($this->post['is_project']) : "";
  135. if($is_project===""){
  136. return error_show(1002,"参数is_project不能为空");
  137. }
  138. if($is_project==1){
  139. $projectNo= isset($this->post['projectNo']) && $this->post['projectNo'] !=="" ? trim($this->post['projectNo']) : "";
  140. if($projectNo===""){
  141. return error_show(1002,"参数projectNo不能为空");
  142. }
  143. }
  144. $khNo = isset($this->post['khNo']) && $this->post['khNo'] !=="" ? trim($this->post['khNo']) : "";
  145. if($khNo===""){
  146. return error_show(1002,"参数khNo不能为空");
  147. }
  148. $kehu= \app\admin\common\User::getIns()->handle("cInfo",['companyNo'=>$khNo]);
  149. if($kehu['code']!=0) return error_show($kehu['code'],$kehu['message']);
  150. $kehu_info = $kehu['data']??[];
  151. $area = isset($this->post['area']) && $this->post['area'] !=="" ? trim($this->post['area']) : ($kehu_info['area']??"");
  152. if($area==='')return error_show(1002,"客户区域不能为空");
  153. $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !=="" ? trim($this->post['companyNo']) : "";
  154. if($companyNo===""){
  155. return error_show(1002,"参数companyNo不能为空");
  156. }
  157. $companyinfo= \app\admin\common\User::getIns()->handle("getCodeAndName",['code'=>$companyNo]);
  158. if($companyinfo['code']!=0) return error_show($companyinfo['code'],$companyinfo['message']);
  159. $companyName = $companyinfo['data'][$companyNo]??"";
  160. $endtime = isset($this->post['endtime']) && $this->post['endtime'] !=="" ? $this->post['endtime'] : "";
  161. if($endtime===""){
  162. return error_show(1002,"参数endtime不能为空");
  163. }
  164. $platform_code = isset($this->post['platform_code']) && $this->post['platform_code'] !=="" ? trim($this->post['platform_code']) : "";
  165. if($platform_code===""){
  166. return error_show(1002,"参数platform_code不能为空");
  167. }
  168. $platform = Db::name('platform')
  169. ->field('id,status,is_select_pay_rate')
  170. ->where(['is_del' => 0, 'id' => $platform_code])
  171. ->findOrEmpty();
  172. if (empty($platform)) return json_show(1004, '该平台不存在');
  173. if ($platform['status'] != 1) return json_show(1004, '该平台已禁用');
  174. $pay_id = $platform_code;
  175. if ($platform['is_select_pay_rate'] == 1&& channel_is_company($platform_code,$companyNo))return error_show(1004, "平台渠道包含当前业务公司");
  176. $ladder = isset($this->post['ladder'])&&!empty($this->post['ladder']) ? $this->post['ladder']:"";
  177. if($ladder==""){
  178. return error_show(1005,"参数ladder不能为空");
  179. }
  180. $createrid= $this->uid;//isset($user["data"]['id']) ? $user["data"]['id'] : "";
  181. $creater= $this->uname;//isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  182. $depart = Db::connect('mysql_sys')
  183. ->name('account_item')
  184. ->field('itemid')
  185. ->where('account_id',$createrid)
  186. ->findOrEmpty();
  187. $zxNo=makeNo("ZX");
  188. Db::startTrans();
  189. try{
  190. $data=[
  191. "zxNo"=>$zxNo,
  192. "createrid"=>$createrid,
  193. "creater"=>$creater,
  194. "is_project"=>$is_project,
  195. "projectNo"=>isset($projectNo) ? $projectNo:"",
  196. "khNo"=>$khNo,
  197. "khName"=>$kehu_info['companyName']??"",
  198. "companyNo"=>$companyNo,
  199. "companyName"=>$companyName,
  200. "area"=>$area,
  201. "endtime"=>$endtime,
  202. "salesman"=>$creater,
  203. "platform_code"=>$platform_code,
  204. "saleid"=>$createrid,
  205. "depart"=>isset($depart['itemid'])?$depart['itemid']:0,
  206. "pay_id"=>$pay_id,
  207. "status"=>0,
  208. "is_del"=>0,
  209. "addtime"=>date("Y-m-d H:i:s"),
  210. "updatetime"=>date("Y-m-d H:i:s"),
  211. ];
  212. $zx = Db::name("consult_order")->insert($data);
  213. if($zx){
  214. //判断是否是项目,且该项目是否存在台账记录中
  215. if($is_project==1) $stand_exists=Db::name('standing_book')->field('id')->where('projectNo',$projectNo)->find();
  216. foreach ($ladder as $value){
  217. $infoNo=makeNo("IF");
  218. $specinfo=[];
  219. if(isset($value['specinfo']) &&!empty($value['specinfo'])){
  220. foreach ($value["specinfo"] as $v){
  221. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  222. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  223. $v['spec_name']=isset($spec['spec_name'])? $spec['spec_name']:"";
  224. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"" ;
  225. $specinfo[]=$v;
  226. }
  227. }
  228. $info=[
  229. "infoNo"=>$infoNo,
  230. "zxNo"=>$zxNo,
  231. "spuCode"=>"",
  232. "good_name"=>$value['good_name'],
  233. "good_img"=>$value['good_img'],
  234. "cat_id"=>$value['cat_id'],
  235. "unit"=>$value['unit'],
  236. "brand_id"=>$value['brand_id'],
  237. "arrival_time"=>$value['arrival_time'],
  238. "specinfo"=>empty($specinfo)?"" : json_encode($specinfo),
  239. "cost_desc" => isset($value['cost_desc']) ? $value['cost_desc'] : '',
  240. "is_addrs"=>$value['is_addrs'],
  241. "is_custom"=>$value['is_custom'],
  242. "metal_id"=>$value['metal_id'],
  243. "config"=>isset($value['config'])?$value['config']:"",
  244. "other_config"=>isset($value['other_config'])?$value['other_config']:"",
  245. "specs_weight"=>isset($value['specs_weight'])?$value['specs_weight']:"0",
  246. "gold_price"=>isset($value['gold_price'])?$value['gold_price']:"0",
  247. "is_gold_price"=>isset($value['is_gold_price'])?$value['is_gold_price']:"0",
  248. "total_weight"=>isset($value['total_weight'])?$value['total_weight']:"0",
  249. "budget_price"=>$value['budget_price'],
  250. "num"=>$value['num'],
  251. "pgNo"=>isset($value['pgNo'])&&$value['pgNo']!==""?trim($value['pgNo']):"",
  252. "use_desc"=>$value['use_desc']??'',
  253. "remark"=>$value['remark'],
  254. "status"=>1,
  255. "is_del"=>0,
  256. "addtime"=>date("Y-m-d H:i:s"),
  257. "updatetime"=>date("Y-m-d H:i:s"),
  258. 'enclosure_file'=>isset($value['enclosure_file'])?$value['enclosure_file']:'',
  259. ];
  260. $up = Db::name("consult_info")->insertGetId($info);
  261. if(!$up){
  262. Db::rollback();
  263. return error_show(1004,'添加失败');
  264. }else{
  265. //修改状态
  266. ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
  267. "order_code" => $infoNo,//咨询单详情编号
  268. "status" => 1,//这里的status是之前的值
  269. "action_remark" => '',//备注
  270. "action_type" => "create"//新建create,编辑edit,更改状态status
  271. ], "ZXD", 1, $info);
  272. //竞价单不走流程,不推待办已办
  273. // ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
  274. // "order_type" => 'ZXD',
  275. // "order_code" => $infoNo,//咨询单详情编号
  276. // "order_id" => $up,
  277. // "order_status" => 1,
  278. // 'before_status'=>0
  279. // ]);
  280. //如果存在该项目编码,更新对应的第一个竞价单编码,其他竞价单编码新增(带着项目编码)
  281. if (isset($stand_exists)) {
  282. Db::name('standing_book')
  283. ->where('id', $stand_exists['id'])
  284. ->update([
  285. 'infoNo' => $infoNo,
  286. 'updatetime' => date('Y-m-d H:i:s')
  287. ]);
  288. unset($stand_exists);//后面的竞价单编码不用更新,都是新增
  289. } else {
  290. //添加台账信息
  291. Db::name('standing_book')
  292. ->insert([
  293. 'standBookNo' => makeNo("IO"),
  294. 'projectNo' => isset($projectNo) ? $projectNo : '',
  295. 'infoNo' => $infoNo,
  296. 'companyNo' => $companyNo,
  297. 'customer_code' => $khNo,
  298. 'addtime' => date('Y-m-d H:i:s'),
  299. 'updatetime' => date('Y-m-d H:i:s')
  300. ]);
  301. }
  302. }
  303. }
  304. Db::commit();
  305. return app_show(0,"新建成功",["zxNo"=>$zxNo]);
  306. }else{
  307. Db::rollback();
  308. return error_show(1004,"新建失败");
  309. }
  310. }catch (\Exception $e){
  311. Db::rollback();
  312. return error_show(1003,$e->getMessage());
  313. }
  314. }
  315. public function zxinfo(){
  316. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  317. if($infoNo==""){
  318. return error_show(1004,"参数infoNo不能为空");
  319. }
  320. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  321. if($zxinfo==false){
  322. return error_show(1004,"未找到信息数据");
  323. }
  324. $zxorder = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
  325. if($zxorder==false){
  326. return error_show(1004,"未找到咨询信息数据");
  327. }
  328. $budget = get_budget($zxinfo['cat_id'], $zxorder['companyNo'], $zxorder['platform_code']);
  329. $zxinfo['can']= isset($zxinfo['cat_id']) && $zxinfo['cat_id'] !=0 ? made($zxinfo['cat_id'],[]):[];
  330. $zxinfo['khname']="";
  331. $zxinfo['original_price']=sprintf("%.2f",$zxinfo['budget_price']* (1 -$budget));
  332. $zxinfo['khNo'] = $zxorder['khNo'];
  333. $zxinfo['area'] = $zxorder['area'];
  334. $zxinfo['brand_id']=$zxinfo['brand_id']==0 ?"":$zxinfo['brand_id'];
  335. $zxinfo['brand']="";
  336. $zxinfo['companyNo']=isset($zxorder['companyNo'])?$zxorder['companyNo']:"";
  337. $zxinfo['projectNo']=isset($zxorder['projectNo'])?$zxorder['projectNo']:"";
  338. $zxinfo['is_project']=isset($zxorder['is_project'])?$zxorder['is_project']:"";
  339. $zxinfo['company']="";
  340. $zxinfo['endtime']=isset($zxorder['endtime'])?$zxorder['endtime']:"";
  341. $zxinfo['platform_code'] =isset($zxorder['platform_code'])?$zxorder['platform_code']:"";
  342. $zxinfo['salesman'] =isset($zxorder['salesman'])?$zxorder['salesman']:"";
  343. $zxinfo['saleid'] =isset($zxorder['saleid'])?$zxorder['saleid']:"";
  344. $zxinfo['depart'] =isset($zxorder['depart'])?$zxorder['depart']:"";
  345. $zxinfo['project_name']="";
  346. $zxinfo['budget_total']="";
  347. $zxinfo['departinfo']=[];
  348. $zxinfo['unit_name']="";
  349. $zxinfo['metal_name']=isset($zxinfo['metal_id'])&& $zxinfo['metal_id']!=0?$this->noble[$zxinfo['metal_id']]:"";
  350. $zxinfo['specinfo']=json_decode($zxinfo['specinfo'],true);
  351. $userCommon = \app\admin\common\User::getIns();
  352. $tmp = $userCommon->handle('getCodeAndName', ['code' => [$zxorder['companyNo'],$zxorder['khNo']]]);
  353. if($zxinfo['unit']!==""){
  354. $unit=Db::name("unit")->where(['id'=>$zxinfo['unit']])->find();
  355. $zxinfo['unit_name']= isset($unit['unit'])?$unit['unit']:"";
  356. }
  357. if($zxinfo['brand_id']!==""){
  358. $unit=Db::name("brand")->where(['id'=>$zxinfo['brand_id']])->find();
  359. $zxinfo['brand']= isset($unit['brand_name'])?$unit['brand_name']:"";
  360. }
  361. $zxinfo['company'] = $tmp['data'][$zxorder['companyNo']] ?? '';
  362. $zxinfo['khname'] = $tmp['data'][$zxorder['khNo']] ?? '';
  363. // }
  364. if($zxorder['is_project']==1 && $zxorder['projectNo']!==""){
  365. $project = Db::name("project")->where(["projectNo"=>$zxorder['projectNo'],"is_del"=>0])->find();
  366. $zxinfo['project_name']=isset($project['project_name'])?$project['project_name']:"";
  367. $zxinfo['budget_total']=isset($project['budget_total'])?$project['budget_total']:"";
  368. $zxinfo['project_use_desc']=isset($project['use_desc'])?$project['use_desc']:"";
  369. $projectinfo = Db::name("project_info")->where(["pgNo"=>$zxinfo['pgNo']])->find();
  370. $zxinfo['pgNo'] = isset($projectinfo['pgNo']) ? $projectinfo['pgNo']:"";
  371. }
  372. if($zxorder['depart']>0){
  373. $tmp = $userCommon->handle('ciinfo',['id'=>$zxorder['depart']]);
  374. $zxinfo['departinfo']=$tmp['data'];
  375. }
  376. if($zxorder['platform_code']>0){
  377. $palt=Db::name("platform")->where(["id"=>$zxorder['platform_code']])->find();
  378. $zxinfo['platform_name']=isset($palt['platform_name'])?$palt['platform_name']:"";
  379. }
  380. return app_show(0,"获取成功",$zxinfo);
  381. }
  382. public function zxedit(){
  383. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  384. if($infoNo==""){
  385. return error_show(1004,"参数infoNo不能为空");
  386. }
  387. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  388. if($zxinfo==false){
  389. return error_show(1004,"未找到信息数据");
  390. }
  391. $enclosure_file =isset($this->post['enclosure_file'])&&$this->post['enclosure_file']!=""?trim($this->post['enclosure_file']):$zxinfo['enclosure_file'];
  392. $good_name= isset($this->post['good_name'])&&$this->post['good_name']!=""?trim($this->post['good_name']):"";
  393. if($good_name==""){
  394. return error_show(1003,"参数good_name不能为空");
  395. }
  396. $good_img= isset($this->post['good_img'])&&$this->post['good_img']!=""?trim($this->post['good_img']):"";
  397. if($good_img==""){
  398. return error_show(1003,"参数good_img不能为空");
  399. }
  400. $cat_id= isset($this->post['cat_id'])&&$this->post['cat_id']!=""?intval($this->post['cat_id']):"";
  401. if($cat_id==""){
  402. return error_show(1003,"参数cat_id不能为空");
  403. }
  404. $unit= isset($this->post['unit'])&&$this->post['unit']!=""?trim($this->post['unit']):"";
  405. if($unit==""){
  406. return error_show(1003,"参数unit不能为空");
  407. }
  408. $brand_id= isset($this->post['brand_id'])&&$this->post['brand_id']!==""?intval($this->post['brand_id']):"0";
  409. $arrival_time= isset($this->post['arrival_time'])&&$this->post['arrival_time']!=""?$this->post['arrival_time']:"";
  410. if($arrival_time==""){
  411. return error_show(1003,"参数arrival_time不能为空");
  412. }
  413. $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
  414. if($specin==""){
  415. return error_show(1003,"参数specinfo不能为空");
  416. }
  417. $cost_desc= isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""?trim($this->post['cost_desc']):"";
  418. // if($cost_desc==""){
  419. // return error_show(1003,"参数cost_desc不能为空");
  420. // }
  421. $is_addrs= isset($this->post['is_addrs'])&&$this->post['is_addrs']!==""?intval($this->post['is_addrs']):"";
  422. if($is_addrs===""){
  423. return error_show(1003,"参数is_addrs不能为空");
  424. }
  425. $is_custom= isset($this->post['is_custom'])&&$this->post['is_custom']!==""?trim($this->post['is_custom']):"";
  426. if($is_custom===""){
  427. return error_show(1003,"参数is_custom不能为空");
  428. }
  429. $metal_id= isset($this->post['metal_id'])&&$this->post['metal_id']!==""?intval($this->post['metal_id']):"";
  430. if($metal_id===""){
  431. return error_show(1003,"参数metal_id不能为空");
  432. }
  433. $config = isset($this->post['config'])&& $this->post['config']!=""?trim($this->post['config']):"";
  434. $other_config = isset($this->post['other_config'])&& $this->post['other_config']!=""?trim($this->post['other_config']):"";
  435. $specs_weight = isset($this->post['specs_weight'])&& $this->post['specs_weight']!==""?floatval($this->post['specs_weight']):"";
  436. $gold_price = isset($this->post['gold_price'])&& $this->post['gold_price']!==""?floatval($this->post['gold_price']):"";
  437. $is_gold_price = isset($this->post['is_gold_price'])&& $this->post['is_gold_price']!==""?intval($this->post['is_gold_price']):"0";
  438. $budget_price = isset($this->post['budget_price'])&& $this->post['budget_price']!==""?floatval($this->post['budget_price']):"";
  439. $total_weight = isset($this->post['total_weight'])&& $this->post['total_weight']!==""?floatval($this->post['total_weight']):"";
  440. $num = isset($this->post['num'])&& $this->post['num']!==""?intval($this->post['num']):"";
  441. if($num===""){
  442. return error_show(1003,"参数num不能为空");
  443. }
  444. if($budget_price===""){
  445. return error_show(1003,"参数budget_price不能为空");
  446. }
  447. $pgNo = isset($this->post['pgNo'])&& $this->post['pgNo']!="" ? trim($this->post['pgNo']):"";
  448. $use_desc = isset($this->post['use_desc'])&& $this->post['use_desc']!="" ? trim($this->post['use_desc']):"";
  449. $isbids = isset($this->post['isbids'])&& $this->post['isbids']!="" ? intval($this->post['isbids']):"1";
  450. $zxorder = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo']])->field("area,is_project")->findOrEmpty();
  451. if(empty($zxorder))return error_show(1003,"咨询信息未找到");
  452. if($isbids==0){
  453. if($zxorder['is_project']==1)return error_show(1003,"项目类型咨询单不可进行此项编辑");
  454. }
  455. $area = isset($this->post['area'])&& $this->post['area']!="" ? trim($this->post['area']):$zxorder['area'];
  456. $remark = isset($this->post['remark'])&& $this->post['remark']!="" ? trim($this->post['remark']):"";
  457. if($remark==""){
  458. return error_show(1003,"参数remark不能为空");
  459. }
  460. $endtime = isset($this->post['endtime'])&& $this->post['endtime']!="" ? trim($this->post['endtime']):"";
  461. if($endtime==""){
  462. return error_show(1003,"参数endtime不能为空");
  463. }
  464. if($metal_id!=0){
  465. if($config==""){
  466. return error_show(1003,"参数config不能为空");
  467. }
  468. if($other_config==""){
  469. return error_show(1003,"参数other_config不能为空");
  470. }
  471. if($specs_weight===""){
  472. return error_show(1003,"参数specs_weight不能为空");
  473. }
  474. if($gold_price===""){
  475. return error_show(1003,"参数gold_price不能为空");
  476. }
  477. }
  478. $specinfo=[];
  479. foreach ($specin as $v){
  480. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  481. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  482. $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
  483. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
  484. $specinfo[]=$v;
  485. }
  486. Db::startTrans();
  487. try{
  488. $innew =makeNo("IF");
  489. $info=[
  490. "infoNo"=>$innew,
  491. "zxNo"=>$zxinfo['zxNo'],
  492. "spuCode"=>"",
  493. "good_name"=>$good_name,
  494. "good_img"=>$good_img,
  495. "cat_id"=>$cat_id,
  496. "unit"=>$unit,
  497. "brand_id"=>$brand_id,
  498. "arrival_time"=>$arrival_time,
  499. "specinfo"=>json_encode($specinfo),
  500. "cost_desc"=>$cost_desc,
  501. "is_addrs"=>$is_addrs,
  502. "is_custom"=>$is_custom,
  503. "metal_id"=>$metal_id,
  504. "config"=>$config,
  505. "other_config"=>$other_config,
  506. "specs_weight"=>$specs_weight===""?0:$specs_weight,
  507. "gold_price"=>$gold_price===""? 0 : $gold_price,
  508. "is_gold_price"=>$is_gold_price===""?0:$is_gold_price,
  509. "total_weight"=>$total_weight===""? $num*$specs_weight :$total_weight,
  510. "budget_price"=>$budget_price,
  511. "num"=>$num,
  512. "pgNo"=>$pgNo,
  513. "use_desc"=>$use_desc,
  514. "remark"=>$remark,
  515. "bargain_num"=>$zxinfo['bargain_num']+1,
  516. "status"=>1,
  517. "is_del"=>0,
  518. "addtime"=>date("Y-m-d H:i:s"),
  519. "updatetime"=>date("Y-m-d H:i:s"),
  520. 'bargain_status'=>1,
  521. 'enclosure_file'=>$enclosure_file
  522. ];
  523. $up = Db::name("consult_info")->insert($info);
  524. if($up){
  525. //操作记录
  526. ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], [
  527. "order_code" => $innew,//咨询单详情编号
  528. "status" => 1,//这里的status是之前的值
  529. "action_remark" => '',//备注
  530. "action_type" => "edit"//新建create,编辑edit,更改状态status
  531. ], "ZXD", 1, $this->post);
  532. // ProcessOrder::AddProcess($this->post['token'], [
  533. // "order_type" => 'ZXD',
  534. // "order_code" => $innew,//咨询单详情编号
  535. // "order_id" => 0,
  536. // "order_status" => 1
  537. // ]);
  538. if($isbids==1){
  539. $bidlist = Db::name("consult_bids")->where(["infoNo"=>$zxinfo['infoNo'],"is_del"=>0])->select()->toArray();
  540. if (!empty($bidlist)){
  541. foreach ($bidlist as $value){
  542. unset($value['id']);
  543. $value['infoNo']=$innew;
  544. $value['bidNo']=makeNo("BD");
  545. $value['spuCode']=makeNo("SKU");
  546. $value['status'] =0;
  547. $value['updatetime'] =date("Y-m-d H:i:s");
  548. $in = Db::name("consult_bids")->insert($value);
  549. if($in==false)throw new \Exception("反馈商品新建失败");
  550. ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], [
  551. "order_code" => $innew,//咨询单详情编号
  552. "status" => 1,//这里的status是之前的值
  553. "action_remark" => '',//备注
  554. "action_type" => "create"//新建create,编辑edit,更改状态status
  555. ], "FKD", 1, $this->post);
  556. }
  557. }
  558. }
  559. $zxinfo["bargain_status"] =1;
  560. $zxinfo["status"] =6;
  561. $zxinfo["bargain_code"] =$innew;
  562. $zxinfo["updatetime"] =date("Y-m-d H:i:s");
  563. $bar=Db::name("consult_info")->save($zxinfo);
  564. if($bar==false)throw new \Exception("反馈商品更新失败");
  565. //修改状态,添加待办
  566. ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], [
  567. "order_code" => $zxinfo['infoNo'],//咨询单详情编号
  568. "status" => $zxinfo['status'],//这里的status是之前的值
  569. "action_remark" => '',//备注
  570. "action_type" => "edit"//新建create,编辑edit,更改状态status
  571. ], "ZXD", $zxinfo['status'], $zxinfo);
  572. //更新consule_order记录
  573. $op = Db::name('consult_order')->where('zxNo',$zxinfo['zxNo'])->update(['endtime'=>$endtime,'area'=>$area, 'updatetime'=>date('Y-m-d H:i:s')]);
  574. if($op==false)throw new \Exception("咨询单结束时间更新失败");
  575. //维护台账记录
  576. $insert_standing_book_data=[
  577. 'standBookNo'=>makeNo('IO'),
  578. 'infoNo'=>$innew,
  579. 'addtime' => date('Y-m-d H:i:s'),
  580. 'updatetime' => date('Y-m-d H:i:s')
  581. ];
  582. $temp_project = Db::name('consult_order')->field('id,projectNo,khNo,companyNo')->where(['zxNo'=>$zxinfo['zxNo'], 'is_del'=>0])->find();
  583. if(!empty($temp_project)){
  584. $insert_standing_book_data['projectNo']=$temp_project['projectNo'];
  585. $insert_standing_book_data['companyNo']=$temp_project['companyNo'];
  586. $insert_standing_book_data['customer_code']=$temp_project['khNo'];
  587. }
  588. Db::name('standing_book')->insert($insert_standing_book_data);
  589. Db::commit();
  590. return app_show(0,"咨询新建成功",["infoNo"=>$innew]);
  591. }
  592. }catch (\Exception $e){
  593. Db::rollback();
  594. return error_show(1004,$e->getMessage());
  595. }
  596. }
  597. //** 发布竞标任务 */
  598. public function bargain(){
  599. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  600. if($infoNo==""){
  601. return error_show(1004,"参数infoNo不能为空");
  602. }
  603. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  604. if($zxinfo==false){
  605. return error_show(1004,"未找到信息数据");
  606. }
  607. $status =isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
  608. if($status===""){
  609. return error_show(1004,"参数status不能为空");
  610. }
  611. // if($status==1&&$zxinfo['status']>1){
  612. // $zxinfo['bargain_num']=+1;
  613. // }
  614. $old_zxinfo_status = $zxinfo['status'];
  615. $zxinfo['status']=$status;
  616. $zxinfo['updatetime']=date("Y-m-d H:i:s");
  617. $up = Db::name("consult_info")->save($zxinfo);
  618. if($up){
  619. //修改状态,添加待办
  620. ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
  621. "order_code" => $zxinfo['infoNo'],//咨询单详情编号
  622. "status" => $old_zxinfo_status,//这里的status是之前的值
  623. "action_remark" => '',//备注
  624. "action_type" => "status"//新建create,编辑edit,更改状态status
  625. ], "ZXD", $zxinfo['status'], $zxinfo);
  626. return app_show(0,"状态更新成功");
  627. }else{
  628. return error_show(1003,"状态更新失败");
  629. }
  630. }
  631. //反馈商品添加
  632. public function feadback(){
  633. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  634. if($infoNo==""){
  635. return error_show(1002,"参数infoNo不能为空");
  636. }
  637. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  638. if($zxinfo==false){
  639. return error_show(1003,"未找到信息数据");
  640. }
  641. if($zxinfo['status']!=1){
  642. return error_show(1004,"任务未进行");
  643. }
  644. $zx = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
  645. if($zx==false){
  646. return error_show(1003,"未找咨询信息数据");
  647. }
  648. $good_name = isset($this->post['good_name'])&&$this->post['good_name']!=""? trim($this->post['good_name']):"";
  649. if($good_name==""){
  650. return error_show(1002,"参数good_name不能为空");
  651. }
  652. $brandid = isset($this->post['brand_id'])&&$this->post['brand_id']!=""? intval($this->post['brand_id']):"";
  653. $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? trim($this->post['cat_id']):"";
  654. if($cat_id==""){
  655. return error_show(1002,"参数cat_id不能为空");
  656. }
  657. $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
  658. if($specin==""){
  659. return error_show(1003,"参数specinfo不能为空");
  660. }
  661. $specinfo=[];
  662. foreach ($specin as $v){
  663. $spec =Db::name("specs")->where(["id"=>$v['spec_id']])->find();
  664. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  665. $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
  666. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
  667. $specinfo[]=$v;
  668. }
  669. $unit_id = isset($this->post['unit_id'])&&$this->post['unit_id']!=""? intval($this->post['unit_id']):"";
  670. $is_combind = isset($this->post['is_combind'])&&$this->post['is_combind']!=""? intval($this->post['is_combind']):"0";
  671. $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""? trim($this->post['cost_desc']):"";
  672. $work_day = isset($this->post['work_day'])&&$this->post['work_day']!=""? intval($this->post['work_day']):"";
  673. $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!=""? intval($this->post['delivery_day']):"";
  674. $good_img = isset($this->post['good_img'])&&$this->post['good_img']!=""? $this->post['good_img']:[];
  675. $expire_day = isset($this->post['expire_day'])&&$this->post['expire_day']!=""? intval($this->post['expire_day']) :"";
  676. $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!=""? trim($this->post['origin_place']):"";
  677. $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
  678. // $supplier_account = checkHasAccountBySupplierNos([$supplierNo]);
  679. $cgd_supplier_code = isset($this->post['cgd_supplier_code'])&&$this->post['cgd_supplier_code']!=''? trim($this->post['cgd_supplier_code']):'';
  680. $cgd_apply_id = isset($this->post['cgd_apply_id'])&&$this->post['cgd_apply_id']!=''? trim($this->post['cgd_apply_id']):0;
  681. $cgd_apply_name = isset($this->post['cgd_apply_name'])&&$this->post['cgd_apply_name']!=''? trim($this->post['cgd_apply_name']):'';
  682. $supplier_origin_price = isset($this->post['supplier_origin_price'])&&$this->post['supplier_origin_price']!=''? floatval($this->post['supplier_origin_price']):0;
  683. $user= \app\admin\common\User::getIns();
  684. $supplier =$user->handle("getCodeAndName",["code"=>[$supplierNo,$cgd_supplier_code]]);
  685. $supplierName = isset($supplier['data'][$supplierNo])?$supplier['data'][$supplierNo]:"";
  686. $cgd_supplier_name= $supplier['data'][$cgd_supplier_code]??'';
  687. // if(isset($supplier_account[$supplierNo])){
  688. // if($cgd_supplier_code=='')return error_show(1004,'采购供应商信息不能为空');
  689. // if($cgd_apply_id=='')return error_show(1004,'采购竞单人信息不能为空');
  690. // if($supplier_origin_price==='')return error_show(1004,'采购供应商信息采购成本不能为空');
  691. // $cgd_supplier_name= $supplier['data'][$cgd_supplier_code]??'';
  692. // }
  693. $pay_way = isset($this->post['pay_way'])&&$this->post['pay_way']!=""? intval($this->post['pay_way']):"";
  694. $tax = isset($this->post['tax'])&&$this->post['tax']!=""? trim($this->post['tax']):"";
  695. $send_way = isset($this->post['send_way'])&&$this->post['send_way']!=""? intval($this->post['send_way']):"";
  696. $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!=""? intval($this->post['metal_id']):"0";
  697. $is_gold_price = isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!=""? intval($this->post['is_gold_price']):"0";
  698. $config = isset($this->post['config'])&&$this->post['config']!=""? $this->post['config']:"";
  699. $other_config = isset($this->post['other_config'])&&$this->post['other_config']!=""? $this->post['other_config']:"";
  700. $weight = isset($this->post['weight'])&&$this->post['weight']!==""? floatval($this->post['weight']):"0";
  701. $good_weight = isset($this->post['noble_weight'])&&$this->post['noble_weight']!==""? floatval($this->post['noble_weight']):"0";
  702. $demo_fee = isset($this->post['demo_fee'])&&$this->post['demo_fee']!==""? floatval($this->post['demo_fee']):"0";
  703. $delivery_fee = isset($this->post['delivery_fee'])&&$this->post['delivery_fee']!==""? floatval($this->post['delivery_fee']):"0";
  704. $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!==""? floatval($this->post['open_fee']):"0";
  705. $pakge_fee = isset($this->post['pakge_fee'])&&$this->post['pakge_fee']!==""? floatval($this->post['pakge_fee']):"0";
  706. $nake_fee = isset($this->post['nake_fee'])&&$this->post['nake_fee']!==""? floatval($this->post['nake_fee']):"0";
  707. $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!==""? floatval($this->post['mark_fee']):"0";
  708. $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!==""? floatval($this->post['cert_fee']):"0";
  709. $cost_fee = isset($this->post['cost_fee'])&&$this->post['cost_fee']!==""? floatval($this->post['cost_fee']):"0";
  710. if($nake_fee==="" ){
  711. return error_show(1004,"参数nake_fee不能为空");
  712. }
  713. $is_diff = isset($this->post['is_diff'])&&$this->post['is_diff']!==""? intval($this->post['is_diff']):"";
  714. $supply_area = isset($this->post['supply_area'])&&$this->post['supply_area']!==""? intval($this->post['supply_area']):"";
  715. $remark = isset($this->post['remark'])&&$this->post['remark']!=""? trim($this->post['remark']):"";
  716. $delivery_place = isset($this->post['delivery_place'])&& $this->post['delivery_place']!='' ? trim($this->post['delivery_place']):"";
  717. if($delivery_place==''){
  718. return error_show(1002,"参数delivery_place不能为空");
  719. }
  720. $relaComNo = isset($this->post['relaComNo']) && $this->post['relaComNo'] != '' ? trim($this->post['relaComNo']) : "";
  721. if ($relaComNo == '') return error_show(1004, '关联公司不能为空');
  722. $createrid= $this->uid;//isset($user["data"]['id']) ? $user["data"]['id'] : "";
  723. $creater= $this->uname;//isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  724. $bidNo=makeNo("BD");
  725. $spucode=makeNo("SKU");
  726. $goodBind= isset($this->post['goodBind']) && !empty($this->post['goodBind']) ? $this->post['goodBind'] :[];
  727. if($is_combind==1){
  728. if(empty($goodBind))$this->error('组合商品商品明细不能为空');
  729. $spucode=makeNo('SSU');
  730. }
  731. //计算毛利率
  732. $budget = get_budget($zxinfo['cat_id'], $zx['companyNo'], $zx['platform_code']);
  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. $god=[
  975. "metal_id"=>$info['metal_id'],
  976. "weight"=>$info["good_weight"],
  977. "demo_fee"=>$info["demo_fee"],
  978. "delivery_fee"=>$info["delivery_fee"],
  979. "open_fee"=>$info["open_fee"],
  980. "packing_fee"=>$info["pakge_fee"],
  981. "mark_fee"=>$info["mark_fee"],
  982. "nake_fee"=>$info["nake_fee"],
  983. "cert_fee"=>$info["cert_fee"],
  984. "cost_fee"=>$info["cost_fee"],
  985. "num"=>$bidinfo["num"],
  986. ];
  987. if($info['is_gold_price']==1){
  988. $price = GoldPrice($god, $budget);
  989. $info['sale_price'] =round($price,2);
  990. }
  991. $info['specinfo'] = json_decode($info['specinfo'],true);
  992. $place = ["provice_code"=>"","city_code"=>"","area_code"=>""];
  993. if($info['delivery_place']!=""){
  994. list($place['provice_code'],$place['city_code'],$place['area_code'])=explode(",",$info['delivery_place']);
  995. }
  996. $info['delivery_place_cn']=GetAddr(json_encode($place));
  997. $place = ["provice_code"=>"","city_code"=>"","area_code"=>""];
  998. if($info['origin_place']!=""){
  999. list($place['provice_code'],$place['city_code'],$place['area_code'])=explode(",",$info['origin_place']);
  1000. }
  1001. $info['origin_place_cn']=GetAddr(json_encode($place));
  1002. $info['metal_name']=isset($info['metal_id'])&& $info['metal_id']!=0?$this->noble[$info['metal_id']]:"";
  1003. $bargain =Db::name("bargain_order")->where(['bidsNo'=>$bidNo,"is_del"=>0])->find();
  1004. $info['bargain'] =$bargain;
  1005. $info['good_img'] = explode(',',$info['good_img']);
  1006. //添加商品创建人字段
  1007. $good_info = Db::name('good_basic')
  1008. ->field('id,createrid,creater')
  1009. ->where('is_del',0)
  1010. ->where('spuCode',$info['spuCode'])
  1011. ->findOrEmpty();
  1012. $info['good_createrid'] = $good_info['createrid']??0;
  1013. $info['good_creater'] = $good_info['creater']??'';
  1014. return app_show(0,"获取成功",$info);
  1015. }
  1016. //反馈商品编辑
  1017. public function feededit(){
  1018. $bidNo= isset($this->post['bidNo'])&&$this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  1019. if($bidNo==""){
  1020. return error_show(1002,"参数bidNo不能为空");
  1021. }
  1022. $bidinfo = Db::name("consult_bids")->where(["bidNo"=>$bidNo,"is_del"=>0])->find();
  1023. if($bidinfo==false){
  1024. return error_show(1003,"未找到信息数据");
  1025. }
  1026. if($bidinfo['status']>=5){
  1027. return error_show(1004,"咨询单已确认无法修改");
  1028. }
  1029. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$bidinfo['infoNo'],"is_del"=>0])->find();
  1030. if($zxinfo==false){
  1031. return error_show(1003,"未找到信息数据");
  1032. }
  1033. $zx = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
  1034. if($zx==false){
  1035. return error_show(1003,"未找咨询信息数据");
  1036. }
  1037. $pname = isset($this->post['good_name'])&&$this->post['good_name']!=""? trim($this->post['good_name']):"";
  1038. if($pname==""){
  1039. return error_show(1002,"参数good_name不能为空");
  1040. }
  1041. $brandid = isset($this->post['brand_id'])&&$this->post['brand_id']!=""? intval($this->post['brand_id']):"";
  1042. // if($brandid==""){
  1043. // return error_show(1002,"参数brandid不能为空");
  1044. // }
  1045. $is_combind = isset($this->post['is_combind'])&&$this->post['is_combind']!=''? intval($this->post['is_combind']):'0';
  1046. $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? trim($this->post['cat_id']):"";
  1047. if($cat_id==""){
  1048. return error_show(1002,"参数cat_id不能为空");
  1049. }
  1050. $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
  1051. if($specin==""){
  1052. return error_show(1003,"参数specinfo不能为空");
  1053. }
  1054. $specinfo=[];
  1055. foreach ($specin as $v){
  1056. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  1057. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  1058. $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
  1059. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
  1060. $specinfo[]=$v;
  1061. }
  1062. $unit_id = isset($this->post['unit_id'])&&$this->post['unit_id']!=""? intval($this->post['unit_id']):"";
  1063. $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""? trim($this->post['cost_desc']):"";
  1064. $work_day = isset($this->post['work_day'])&&$this->post['work_day']!=""? intval($this->post['work_day']):"";
  1065. $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!=""? intval($this->post['delivery_day']):"";
  1066. $good_img = isset($this->post['good_img'])&&$this->post['good_img']!=""? $this->post['good_img']:[];
  1067. $expire_day = isset($this->post['expire_day'])&&$this->post['expire_day']!=""? intval($this->post['expire_day']) :"";
  1068. $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!=""? trim($this->post['origin_place']):"";
  1069. $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
  1070. // $supplier_account = checkHasAccountBySupplierNos([$supplierNo]);
  1071. $cgd_supplier_code = isset($this->post['cgd_supplier_code'])&&$this->post['cgd_supplier_code']!=''? trim($this->post['cgd_supplier_code']):'';
  1072. $cgd_apply_id = isset($this->post['cgd_apply_id'])&&$this->post['cgd_apply_id']!=''? trim($this->post['cgd_apply_id']):0;
  1073. $cgd_apply_name = isset($this->post['cgd_apply_name'])&&$this->post['cgd_apply_name']!=''? trim($this->post['cgd_apply_name']):'';
  1074. $supplier_origin_price = isset($this->post['supplier_origin_price'])&&$this->post['supplier_origin_price']!=''? floatval($this->post['supplier_origin_price']):0;
  1075. $cgd_supplier_name='';
  1076. $user= \app\admin\common\User::getIns();
  1077. $supplier =$user->handle("getCodeAndName",["code"=>[$supplierNo,$cgd_supplier_code]]);
  1078. $supplierName = isset($supplier['data'][$supplierNo])?$supplier['data'][$supplierNo]:"";
  1079. // if(isset($supplier_account[$supplierNo])){
  1080. // if($cgd_supplier_code=='')return error_show(1004,'采购供应商信息不能为空');
  1081. // if($cgd_apply_id=='')return error_show(1004,'采购竞单人信息不能为空');
  1082. // if($supplier_origin_price==='')return error_show(1004,'采购供应商信息采购成本不能为空');
  1083. $cgd_supplier_name= $supplier['data'][$cgd_supplier_code]??'';
  1084. // }
  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. $sale_cost_fee = $bidinfo['sale_cost_fee'];
  1111. $cat_top_list = made($cat_id);
  1112. $cat_top_id = isset($cat_top_list[0]['id']) ? $cat_top_list[0]['id'] : 0;
  1113. if ($is_gold_price == 1 && $cat_top_id == 6) {
  1114. $gold = Db::name("gold_price1")->where(["type"=>$metal_id,"is_del"=>0,"status"=>1])->order("addtime desc")
  1115. ->find();
  1116. //$total_fee(成本合计初始价格) =打样费/购买数量 + 开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价0+运费;
  1117. $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;
  1118. // $saleprice = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee/(1-$budget)* $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  1119. //$saleprice(最终售价) = (开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价)/(1-成本售价/100);
  1120. $saleprice = $total_fee / (1 - $budget);
  1121. //销售工艺费=((开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价)/(1-成本售价/100)-(打样费/购买数量 + 开模费/购买数量 +包装费+加标费+证书费+产品裸价0+运费) )/商品重量-最新金价
  1122. $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"];
  1123. }else{
  1124. $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);
  1125. $total_fee = $demo_fee/$zxinfo['num']+$delivery_fee+$open_fee/$zxinfo['num'] + $cost_fee * $noble_weight + $pakge_fee + $mark_fee+$cert_fee +$nake_fee;
  1126. }
  1127. $userCommon= \app\admin\common\User::getIns();
  1128. $supplier_temp =$userCommon->handle("hqInfo",["code"=>$supplierNo]);
  1129. if($supplier_temp['code']!=0 || empty($supplier_temp['data']) ) return error_show(1004,"供应商信息未找到");
  1130. $supplierArr=$supplier_temp['data']??[];
  1131. // $supplier=$supplierArr['child']??[];
  1132. $goodBind= isset($this->post['goodBind']) && !empty($this->post['goodBind']) ? $this->post['goodBind'] :[];
  1133. if($is_combind==1){
  1134. if(empty($goodBind))$this->error('组合商品商品明细不能为空');
  1135. // $spucode=makeNo('SSU');
  1136. }
  1137. if ($supplierArr['relation_code'] != '') {
  1138. if ($supplierArr['relation_code'] == $zx['companyNo']) return error_show(1004, "业务公司与供应商信息一致");
  1139. //判断支付渠道中是否有相关供应商
  1140. $is_select_pay_rate = Db::name('platform')
  1141. ->where(['is_del' => 0, 'id' => $zx['platform_code'],"status"=>1])
  1142. ->value('is_select_pay_rate', 0);
  1143. if ($is_select_pay_rate == 1) {
  1144. if(channel_is_company($zx['platform_code'],$supplierArr['relation_code'])) return error_show(1004, "平台渠道包含当前供应商公司{$supplierNo}");
  1145. //
  1146. }
  1147. }else{
  1148. if($is_combind==1)$this->error('当前供应商无对应业务公司,不可选择组合商品');
  1149. }
  1150. Db::startTrans();
  1151. try{
  1152. $data=[
  1153. "good_name"=>$pname,
  1154. "brand_id"=>$brandid,
  1155. "cat_id"=>$cat_id,
  1156. "specinfo"=>json_encode($specinfo),
  1157. // "material"=>$material,
  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. $rate = isset($catinfo['rate']) ? $catinfo['rate']/100:0; //业务主管利率
  1523. if($bids['is_gold_price']==1){
  1524. $gold = Db::name("gold_price1")->where(["type"=>$bids['metal_id'],"is_del"=>0,"status"=>1])->order("addtime desc")
  1525. ->find();
  1526. //$saleprice(最终售价) = (开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价)/(1-成本售价/100);
  1527. $total_fe= $bids['demo_fee'] / $coninfo['num']+$bids['delivery_fee']+$bids['open_fee'] / $coninfo['num'] +
  1528. $bids['good_weight']*$gold["price"] +$bids['cost_fee']*$bids['good_weight'] + $bids['pakge_fee'] +$bids['mark_fee'] + $bids['cert_fee'] + $bids['nake_fee'];
  1529. // $saleprice =$total_fe / (1 - $budget);
  1530. $rate_price = $total_fe / (1 - $rate);
  1531. }else{
  1532. $total_fe= $bids['demo_fee']/$coninfo['num']+$bids['delivery_fee']+$bids['open_fee'] /
  1533. $coninfo['num']+$bids['cost_fee']*$bids['good_weight']+$bids['pakge_fee'] +$bids['mark_fee']+ $bids['cert_fee'] + $bids['nake_fee'];
  1534. if($bids['nake_fee']!=0){
  1535. $rate_price = ($total_fe)/ (1 - $rate);
  1536. }else{
  1537. $rate_price =$total_fe/ (1 - $rate);
  1538. }
  1539. }
  1540. $ra_status = $info['status'];
  1541. $info['status']=$status;
  1542. if($status==1){
  1543. if($info['after_price']<$rate_price){
  1544. $info['status']=3;
  1545. if($adjunct=='') return error_show(1005,"越线通过附件不能为空");
  1546. }
  1547. }
  1548. $remark = isset($this->post['remark'])&& $this->post['remark']!=""?trim($this->post['remark']):"";
  1549. $createrid= $this->uid;//isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1550. $creater= $this->uname;//isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1551. Db::startTrans();
  1552. try{
  1553. $examinfo = isset($info['exam_info'])&&$info['exam_info']!="" ? json_decode($info['exam_info'],true):[];
  1554. $examinfo[]=[
  1555. "status"=>$status,
  1556. "info_status"=>$ra_status,
  1557. "remark"=>$remark,
  1558. "adjunct"=>$adjunct,
  1559. "adjunct_name"=>$adjunct_name,
  1560. "createrid"=>$createrid,
  1561. "creater"=>$creater
  1562. ];
  1563. $info['remark'] =$remark;
  1564. $info['exam_info']=json_encode($examinfo) ;
  1565. $info['updatetime'] =date("Y-m-d H:i:s");
  1566. $up =Db::name("bargain_order")->save($info);
  1567. if($up){
  1568. //修改状态,添加待办
  1569. ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
  1570. "order_code" => $bargainNo,//咨询单详情编号
  1571. "status" =>$ra_status,//这里的status是之前的值
  1572. "action_remark" => '',//备注
  1573. "action_type" => "status"//新建create,编辑edit,更改状态status
  1574. ], "YJD", $info['status'], $info);
  1575. $process=["order_code"=>$bargainNo,"order_id"=>$info['id'],"order_status"=>$info['status'],"order_type"=>'YJD',"before_status"=>$ra_status,'holder_id'=>$info['createrid']];
  1576. ProcessOrder::AddProcess(['id' => $this->uid, 'nickname' => $this->uname],$process);
  1577. if($info['status']==1||$info['status']==2||$info['status']==3){
  1578. $bidstatus=$bids['status'];
  1579. $bids['status']=5;
  1580. if($info['status']==1||$info['status']==3){
  1581. $bids['sale_price']=$info['after_price'];
  1582. if($bids['is_gold_price']==1){
  1583. $bids['sale_cost_fee'] = $info['cost_after_price'];
  1584. $bids['gold_price'] =isset($gold["price"])?$gold["price"]:0;
  1585. }
  1586. }else $bids['remark'] = $remark;
  1587. $bids['updatetime']=date("Y-m-d H:i:s");
  1588. $up =Db::name("consult_bids")->save($bids);
  1589. if($up==false){
  1590. Db::rollback();
  1591. return error_show(1004,"数据更新失败");
  1592. }
  1593. ActionLog::logAdd(['id' => $this->uid, 'nickname' => $this->uname], [
  1594. "order_code" => $info["bidsNo"],//咨询单详情编号
  1595. "status" => $bidstatus,//这里的status是之前的值
  1596. "action_remark" => '',//备注
  1597. "action_type" => "status"//新建create,编辑edit,更改状态status
  1598. ], "FKD", $bids['status'], $bids);
  1599. }
  1600. Db::commit();
  1601. return app_show(0,"更新成功");
  1602. }
  1603. }catch (\Exception $e){
  1604. Db::rollback();
  1605. return error_show(1004,$e->getMessage());
  1606. }
  1607. }
  1608. public function bargain_info(){
  1609. $bargainNo = isset($this->post['bargainNo'])&& $this->post['bargainNo']!=""?trim($this->post['bargainNo']):"";
  1610. if($bargainNo===""){
  1611. return error_show(1004,"参数bargainNo不能为空");
  1612. }
  1613. $info =Db::name("bargain_order")->where(['bargainNo'=>$bargainNo,"is_del"=>0])->find();
  1614. if($info==false){
  1615. return error_show(1004,"未找到议价数据");
  1616. }
  1617. $bidinfos = Db::name("consult_bids")->where([["bidNo","=",$info['bidsNo']],["is_del","=",0]])->find();
  1618. if($bidinfos==false){
  1619. return error_show(1004,"未找到商品数据");
  1620. }
  1621. $consultinfos =Db::name("consult_info")->where([["infoNo","=",$bidinfos['infoNo']],["is_del","=",0]])->find();
  1622. if($consultinfos==false){
  1623. return error_show(1004,"未找到咨询商品数据");
  1624. }
  1625. $info['spuCode'] = isset($bidinfos['spuCode'])?$bidinfos['spuCode']:"";
  1626. $info['good_name'] = isset($bidinfos['good_name'])?$bidinfos['good_name']:"";
  1627. $info['good_img'] = isset($bidinfos['good_img'])?$bidinfos['good_img']:"";
  1628. $info['brand_id'] = isset($bidinfos['brand_id'])?$bidinfos['brand_id']:"";
  1629. $info['good_num'] = isset($consultinfos['num'])?$consultinfos['num']:"";
  1630. $info['exam_info'] = isset($info['exam_info'])&&$info['exam_info']!=""?json_decode($info['exam_info'],true):"";
  1631. if($bidinfos['brand_id']!=0){
  1632. $info['brand_id'] = $bidinfos['brand_id'];
  1633. $brand=Db::name("brand")->where(["id"=>$bidinfos['brand_id']])->find();
  1634. $info["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1635. }else{
  1636. $info["brand_name"]="";
  1637. $info["brand_id"]="";
  1638. }
  1639. // $catinfo = Db::name("cat")->where(["id"=>$bidinfos['cat_id']])->find();
  1640. //获取竞价单详情
  1641. $tmp = Db::name('consult_order')
  1642. ->field('id,companyNo,platform_code,area')
  1643. ->where(['is_del'=>0,'zxNo'=>$bidinfos['zxNo']])
  1644. ->findOrEmpty();
  1645. $catinfo = get_budget($bidinfos['cat_id'],$tmp['companyNo']??'',$tmp['platform_code']??0,true);
  1646. $info['can']= isset($bidinfos['cat_id']) && $bidinfos['cat_id'] !=0 ? made($bidinfos['cat_id']):[];
  1647. $unit =Db::name("unit")->where(["id"=>$bidinfos['unit_id']])->find();
  1648. $info['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1649. $bidinfoe = Db::name("consult_info")->where(["infoNo"=>$info["infoNo"]])->find();
  1650. $budget = isset($catinfo['rate']) ? $catinfo['rate']:0;
  1651. $lower_rate = isset($catinfo['rate']) ? $catinfo['rate']:0;//业务烛光
  1652. $info['budget'] =$budget;
  1653. $info['area'] =$tmp['area'];
  1654. $info['rate_status'] =0; //利率状态 0 业务主管利率无法通过 1 财务主管利率无法通过 2 boos利率无法通过 3 完全通过
  1655. if($info['after_rate']>=$catinfo['rate']){
  1656. //业务主管利率
  1657. $info['rate_status'] =1;
  1658. }
  1659. $info['before_rate'] =round($info['before_rate']*100,2);
  1660. $info['sale_price'] =round($bidinfos['origin_price'],2);
  1661. $info['cost_before_price'] =round($bidinfos['origin_cost_fee'],2);
  1662. $info['after_rate'] = round($info['after_rate']*100,2);
  1663. $god=[
  1664. "metal_id"=>$bidinfos['metal_id'],
  1665. "weight"=>$bidinfos["good_weight"],
  1666. "demo_fee"=>$bidinfos["demo_fee"],
  1667. "delivery_fee"=>$bidinfos["delivery_fee"],
  1668. "open_fee"=>$bidinfos["open_fee"],
  1669. "packing_fee"=>$bidinfos["pakge_fee"],
  1670. "mark_fee"=>$bidinfos["mark_fee"],
  1671. "nake_fee"=>$bidinfos["nake_fee"],
  1672. "cert_fee"=>$bidinfos["cert_fee"],
  1673. "cost_fee"=>$bidinfos["cost_fee"],
  1674. "num"=>$bidinfoe["num"],
  1675. ];
  1676. $info['gold_price']=0;
  1677. $info['noble_weight']=$bidinfos['good_weight'];
  1678. if($bidinfos['is_gold_price']==1 &&$bidinfos['metal_id']>0){
  1679. $gold = Db::name("gold_price1")->where(["type"=>$bidinfos["metal_id"],"is_del"=>0,"status"=>1])->order("addtime desc")
  1680. ->find();
  1681. $info['gold_price'] =$gold['price'];
  1682. $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);
  1683. }else{
  1684. if($bidinfos['nake_fee']!=0){
  1685. $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);
  1686. }else{
  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'])/ (1 - $lower_rate);
  1688. }
  1689. }
  1690. $info['cost_desc'] =$bidinfos['cost_desc'];
  1691. $info['work_day'] =$bidinfos['work_day'];
  1692. $info['delivery_day'] =$bidinfos['delivery_day'];
  1693. $info['expire_day'] =$bidinfos['expire_day'];
  1694. $info['origin_place'] =$bidinfos['origin_place'];
  1695. $info['origin_addr'] ="";
  1696. if($bidinfos['origin_place']!=''){
  1697. $code = explode(",",$bidinfos['origin_place']);
  1698. $temp=[];
  1699. $temp['provice_code']=isset($code[0])?$code[0]:"";
  1700. $temp['city_code']=isset($code[1])?$code[1]:"";
  1701. $temp['area_code']=isset($code[2])?$code[2]:"";
  1702. $addr= GetAddr(json_encode($temp));
  1703. $info['origin_addr'] = $addr;
  1704. }
  1705. $info['supplierNo'] =$bidinfos['supplierNo'];
  1706. $user= \app\admin\common\User::getIns();
  1707. $supplier_temp =$user->handle("getCodeAndName",["code"=>$info['supplierNo']]);
  1708. // if($supplier_temp['code']!=0 || empty($supplier_temp['data']) ) throw new Exception('该供应商不存在');
  1709. $supplier=$supplier_temp['data']??[];
  1710. // $supplier = Db::name("supplier")->where(["code"=>$info['supplierNo']])->find();
  1711. $info['supplier_name'] = $supplier[$info['supplierNo']]??"";
  1712. $info['pay_way'] =$bidinfos['pay_way'];
  1713. $info['tax'] =$bidinfos['tax'];
  1714. $info['send_way'] =$bidinfos['send_way'];
  1715. $info['metal_id'] =$bidinfos['metal_id'];
  1716. $info['is_gold_price'] =$bidinfos['is_gold_price'];
  1717. $info['config'] =$bidinfos['config'];
  1718. $info['other_config'] =$bidinfos['other_config'];
  1719. $info['weight'] =$bidinfos['weight'];
  1720. $info['good_weight'] =$bidinfos['good_weight'];
  1721. $info['is_diff'] =$bidinfos['is_diff'];
  1722. $info['demo_fee'] =$bidinfos['demo_fee'];
  1723. $info['delivery_fee'] =$bidinfos['delivery_fee'];
  1724. $info['open_fee'] =$bidinfos['open_fee'];
  1725. $info['pakge_fee'] =$bidinfos['pakge_fee'];
  1726. $info['nake_fee'] =$bidinfos['nake_fee'];
  1727. $info['mark_fee'] =$bidinfos['mark_fee'];
  1728. $info['cert_fee'] =$bidinfos['cert_fee'];
  1729. $info['cost_fee'] =$bidinfos['cost_fee'];
  1730. $info['total_fee'] =$bidinfos['total_fee'];
  1731. $info['supply_area'] =$bidinfos['supply_area'];
  1732. $info['remark'] =$bidinfos['remark'];
  1733. $info['is_addrs'] =$consultinfos['is_addrs'];
  1734. $info['is_custom'] =$consultinfos['is_custom'];
  1735. $info['metal_name']=isset($bidinfos['metal_id'])&& $bidinfos['metal_id']!=0?$this->noble[$bidinfos['metal_id']]:"";
  1736. // $info['sale_price'] =round($bidinfos['sale_price'],2);//议价前价格
  1737. $info['specinfo'] = isset($bidinfos['specinfo'])&&$bidinfos['specinfo']!=""?json_decode($bidinfos['specinfo'],true):[];
  1738. $info['lower_price'] =round($lower_price,2);
  1739. //获取议价原因
  1740. if ($info['result_info_id'] != 0) {
  1741. $info['result_info'] = Db::name('result_info')->where(['result_code' => $info['result_info_id'], 'type' => 7, 'status' => 1, 'is_del' => 0])->value('result');
  1742. } else {
  1743. $info['result_info'] = '';
  1744. }
  1745. return app_show(0,"获取成功",$info);
  1746. }
  1747. public function bidlist(){
  1748. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  1749. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  1750. $where=[['is_del',"=",0]];
  1751. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1752. if ($zxNo !== "") {
  1753. $where[] = ['zxNo','like','%'.$zxNo.'%'];
  1754. }
  1755. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  1756. if ($infoNo !== "") {
  1757. $where[] = ['infoNo','like','%'.$infoNo.'%'];
  1758. }
  1759. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
  1760. if ($bidNo !== "") {
  1761. $where[] = ['bidNo','like','%'.$bidNo.'%'];
  1762. }
  1763. $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
  1764. if ($pgNo !== "") {
  1765. $bidinfo = Db::name("consult_info")->where([["pgNo","=",$pgNo],["is_del","=",0]])->column("infoNo");
  1766. $where[] = ['infoNo','in',$bidinfo];
  1767. }
  1768. $bargain_status = isset($this->post['bargain_status']) && $this->post['bargain_status'] !== "" ? intval($this->post['bargain_status']) : "";
  1769. if ($bargain_status !== "") {
  1770. $bidinfo = Db::name("consult_info")->where([["bargain_status","=",$bargain_status],["is_del","=",0]])->column("infoNo");
  1771. $where[] = ['infoNo','in',$bidinfo];
  1772. }
  1773. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  1774. if ($projectNo !== "") {
  1775. $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column
  1776. ("zxNo");
  1777. $where[] = ['zxNo','in',$zxlist];
  1778. }
  1779. $is_own = isset($this->post['is_own']) ? intval($this->post['is_own']) : "0";
  1780. if($is_own==1){
  1781. // $token = isset($this->post['token']) ? trim($this->post['token']) : "";
  1782. // if($token==""){
  1783. // return error_show(101,'token不能为空');
  1784. // }
  1785. // $apply_id =GetUserInfo($token);
  1786. // if(empty($apply_id)||$apply_id['code']!=0){
  1787. // return error_show(1002,"申请人数据不存在");
  1788. // }
  1789. $rm= $this->uid;//isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
  1790. $where[]=['createrid',"=",$rm];
  1791. }
  1792. $count = Db::name('consult_bids')->where($where)->count();
  1793. $total = ceil($count / $size);
  1794. $page = $page >= $total ? $total : $page;
  1795. $list =Db::name('consult_bids')->where($where)->page($page,$size)->select()->toArray();
  1796. $data=[];
  1797. $user= \app\admin\common\User::getIns();
  1798. $supplier_temp =$user->handle("getCodeAndName",["code"=>array_column($list,"supplierNo")]);
  1799. // if($supplier_temp['code']!=0 || empty($supplier_temp['data']) ) throw new Exception('该供应商不存在');
  1800. $supplier=$supplier_temp['data']??[];
  1801. foreach ($list as $value){
  1802. // $catinfo = Db::name("cat")->where(["id"=>$value['cat_id']])->find();
  1803. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  1804. $unit =Db::name("unit")->where(["id"=>$value['unit_id']])->find();
  1805. $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1806. // $supplier = Db::name("supplier")->where(["code"=>$value['supplierNo']])->find();
  1807. $value['supplierName'] = isset($supplier[$value['supplierNo']])?$supplier[$value['supplierNo']]:"";
  1808. if($value['brand_id']!=0){
  1809. $brand=Db::name("brand")->where(["id"=>$value['brand_id']])->find();
  1810. $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1811. }else{
  1812. $value["brand_name"]="";
  1813. $value["brand_id"]="";
  1814. }
  1815. $bidinfo = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
  1816. $zx = Db::name("consult_order")->where(["zxNo"=>$value["zxNo"]])->find();
  1817. $budget = get_budget($value['cat_id'],$zx['companyNo']??'',$zx['platform_code']??0);
  1818. // $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
  1819. $god=[
  1820. "metal_id"=>$value['metal_id'],
  1821. "weight"=>$value["good_weight"],
  1822. "demo_fee"=>$value["demo_fee"],
  1823. "delivery_fee"=>$value["delivery_fee"],
  1824. "open_fee"=>$value["open_fee"],
  1825. "packing_fee"=>$value["pakge_fee"],
  1826. "mark_fee"=>$value["mark_fee"],
  1827. "nake_fee"=>$value["nake_fee"],
  1828. "cert_fee"=>$value["cert_fee"],
  1829. // "cost_fee"=>$value["cost_fee"],
  1830. "cost_fee"=>$value["sale_cost_fee"]!=$value['origin_cost_fee']? $value["sale_cost_fee"]: $value["cost_fee"],
  1831. //暂时注掉,搞不清楚原因@吴广广
  1832. "num"=>$bidinfo["num"],
  1833. ];
  1834. $top_cat = made($value['cat_id']);
  1835. $top_cat_id = isset($top_cat[0]['id'])?$top_cat[0]['id']:0;
  1836. if($value['is_gold_price']==1 && $top_cat_id==6 ){
  1837. $price = GoldPrice($god, $budget);
  1838. $value['sale_price'] = round($price,2);
  1839. $value['origin_price'] = $value["sale_cost_fee"]!=$value['origin_cost_fee']? $value["sale_price"]:
  1840. $value["origin_price"];
  1841. }
  1842. $value['cost_fee'] =$value['origin_cost_fee'];
  1843. $value['specinfo'] = json_decode($value['specinfo'],true);
  1844. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  1845. $value['bargain_status']=$bidinfo['bargain_status'];
  1846. //reject驳回原因,status==5表示驳回
  1847. $value['reject']=[];
  1848. if ($value['status'] >=5) {
  1849. $value['reject'] = Db::name('bargain_order')
  1850. ->field('id,remark,status')
  1851. ->where(['infoNo' => $infoNo, 'bidsNo' => $value['bidNo']])
  1852. ->whereIn('status', 2)->order("id desc")
  1853. ->find();
  1854. }
  1855. //产地
  1856. $place = ["provice_code"=>"","city_code"=>"","area_code"=>""];
  1857. if($value['delivery_place']!=""){
  1858. list($place['provice_code'],$place['city_code'],$place['area_code'])=explode(",",$value['delivery_place']);
  1859. }
  1860. $value['delivery_place_cn']=GetAddr(json_encode($place));
  1861. $place = ["provice_code"=>"","city_code"=>"","area_code"=>""];
  1862. if($value['origin_place']!=""){
  1863. list($place['provice_code'],$place['city_code'],$place['area_code'])=explode(",",$value['origin_place']);
  1864. }
  1865. $value['origin_addr']=GetAddr(json_encode($place));
  1866. // if($value['origin_place']!=''){
  1867. // $code = explode(",",$value['origin_place']);
  1868. // $temp=[];
  1869. // $temp['provice_code']=isset($code[0])?$code[0]:"";
  1870. // $temp['city_code']=isset($code[1])?$code[1]:"";
  1871. // $temp['area_code']=isset($code[2])?$code[2]:"";
  1872. // $addr= GetAddr(json_encode($temp));
  1873. // $value['origin_addr'] = $addr;
  1874. // }
  1875. $good_info = Db::name('good_basic')
  1876. ->field('id,createrid,creater')
  1877. ->where('is_del',0)
  1878. ->where('spuCode',$value['spuCode'])
  1879. ->findOrEmpty();
  1880. $value['good_createrid']=$good_info['createrid']??$value['createrid'];
  1881. $value['good_creater']=$good_info['creater']??$value['creater'];
  1882. $data[] = $value;
  1883. }
  1884. return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
  1885. }
  1886. public function feedlist(){
  1887. $where=[['is_del',"=",0]];
  1888. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1889. if ($zxNo !== "") {
  1890. $where[] = ['zxNo','=',$zxNo];
  1891. }
  1892. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  1893. if ($infoNo !== "") {
  1894. $where[] = ['infoNo','=',$infoNo];
  1895. }
  1896. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
  1897. if ($bidNo !== "") {
  1898. $where[] = ['bidNo','=',$bidNo];
  1899. }
  1900. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  1901. if ($projectNo !== "") {
  1902. $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column
  1903. ("zxNo");
  1904. $where[] = ['zxNo','in',$zxlist];
  1905. }
  1906. $is_own = isset($this->post['is_own']) ? intval($this->post['is_own']) : "0";
  1907. if($is_own==1){
  1908. $rm= $this->uid;//isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
  1909. $where[]=['createrid',"=",$rm];
  1910. }
  1911. $list =Db::name('consult_bids')->where($where)->select();
  1912. $data=[];
  1913. $user= \app\admin\common\User::getIns();
  1914. $supplier_temp =$user->handle("getCodeAndName",["code"=>array_column($list,"supplierNo")]);
  1915. // if($supplier_temp['code']!=0 || empty($supplier_temp['data']) ) throw new Exception('该供应商不存在');
  1916. $supplier=$supplier_temp['data']??[];
  1917. foreach ($list as $value){
  1918. // $catinfo = Db::name("cat")->where(["id"=>$value['cat_id']])->find();
  1919. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  1920. $unit =Db::name("unit")->where(["id"=>$value['unit_id']])->find();
  1921. $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1922. // $supplier = Db::name("supplier")->where(["code"=>$value['supplierNo']])->find();
  1923. $value['supplierName'] = isset($supplier[$value['supplierNo']])?$supplier[$value['supplierNo']]:"";
  1924. if($value['brand_id']!=0){
  1925. $brand=Db::name("brand")->where(["id"=>$value['brand_id']])->find();
  1926. $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1927. }else{
  1928. $value["brand_name"]="";
  1929. $value["brand_id"]="";
  1930. }
  1931. $bidinfo = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
  1932. // $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
  1933. $zx = Db::name("consult_order")->where(["zxNo"=>$value["zxNo"]])->find();
  1934. $budget = get_budget($value['cat_id'],$zx['companyNo']??'',$zx['platform_code']??0);
  1935. $god=[
  1936. "metal_id"=>$value['metal_id'],
  1937. "weight"=>$value["good_weight"],
  1938. "demo_fee"=>$value["demo_fee"],
  1939. "delivery_fee"=>$value["delivery_fee"],
  1940. "open_fee"=>$value["open_fee"],
  1941. "packing_fee"=>$value["pakge_fee"],
  1942. "mark_fee"=>$value["mark_fee"],
  1943. "nake_fee"=>$value["nake_fee"],
  1944. "cert_fee"=>$value["cert_fee"],
  1945. "cost_fee"=>$value["cost_fee"],
  1946. "num"=>$bidinfo["num"],
  1947. ];
  1948. if ($value['is_gold_price'] == 1 ) {
  1949. $gold = Db::name("gold_price1")->where(["type"=>$value['metal_id'],"is_del"=>0,"status"=>1])->order("addtime desc")
  1950. ->find();
  1951. //$total_fee(成本合计初始价格) =打样费/购买数量 + 开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价0+运费;
  1952. //$saleprice(最终售价) = (开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价)/(1-成本售价/100);
  1953. $saleprice = ($value['demo_fee']/$bidinfo['num']+$value['delivery_fee']+$value["open_fee"]/$bidinfo['num'] +$value["good_weight"] *$gold["price"] +
  1954. $value["cost_fee"] * $value["good_weight"] + $value["pakge_fee"]+ $value["mark_fee"] +$value["cert_fee"] +$value["nake_fee"]) / (1 - $budget);
  1955. // //销售工艺费=((开模费/购买数量 + 商品重量* 最新金价 + 工艺费* 商品重量+包装费+加标费+证书费+产品裸价)/(1-成本售价/100)-(打样费/购买数量 + 开模费/购买数量 +包装费+加标费+证书费+产品裸价0+运费) )/商品重量-最新金价
  1956. // $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"];
  1957. }else{
  1958. if($value["nake_fee"]){
  1959. $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);
  1960. }else{
  1961. $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"]) /
  1962. (1 - $budget);
  1963. }
  1964. }
  1965. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  1966. $value['specinfo'] = json_decode($value['specinfo'],true);
  1967. $value['bargain_status']=$bidinfo['bargain_status'];
  1968. $data[]=$value;
  1969. }
  1970. return app_show(0,"获取成功",$data);
  1971. }
  1972. public function bragain_list()
  1973. {
  1974. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
  1975. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
  1976. $where = [['bo.is_del', "=", 0]];
  1977. $bidsNo = isset($this->post['bidsNo']) && $this->post['bidsNo'] != "" ? trim($this->post['bidsNo']) : "";
  1978. if ($bidsNo != "") {
  1979. $where[] = ["bo.bidsNo", "like", "%$bidsNo%"];
  1980. }
  1981. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1982. if ($zxNo !== "") {
  1983. $where[] = ['bo.zxNo', 'like', "%$zxNo%"];
  1984. }
  1985. $bargainNo = isset($this->post['bargainNo']) && $this->post['bargainNo'] !== "" ? trim($this->post['bargainNo']) : "";
  1986. if ($bargainNo !== "") {
  1987. $where[] = ['bo.bargainNo', 'like', "%$bargainNo%"];
  1988. }
  1989. $status = isset($this->post['status']) && $this->post['status'] !== "" ? intval($this->post['status']) : "";
  1990. if ($status !== "") {
  1991. $where[] = ['bo.status', '=', $status];
  1992. }
  1993. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  1994. if ($infoNo !== "") {
  1995. $where[] = ['bo.infoNo', 'like', "%$infoNo%"];
  1996. }
  1997. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  1998. if ($projectNo !== "") {
  1999. $zxlist = Db::name("consult_order")->where(["projectNo" => $projectNo, "is_del" => 0, "is_project" => 1])->column("zxNo");
  2000. $where[] = ['bo.zxNo', 'in', $zxlist];
  2001. }
  2002. $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
  2003. if ($pgNo !== "") {
  2004. $bidinfo = Db::name("consult_info")->where([["pgNo", "=", $pgNo], ["is_del", "=", 0]])->column("infoNo");
  2005. $where[] = ['bo.infoNo', 'in', $bidinfo];
  2006. }
  2007. $start = isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start'] : "";
  2008. $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] : "";
  2009. if ($start != "") {
  2010. $where[] = ["bo.addtime", ">=", date("Y-m-d H:i:s", strtotime($start))];
  2011. }
  2012. if ($end != "") {
  2013. $where[] = ["bo.addtime", "<=", date("Y-m-d H:i:s", strtotime($end))];
  2014. }
  2015. $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
  2016. if ($company_name !== "") $where[] = ["bo.createrid", 'in', get_company_item_user_by_name($company_name)];
  2017. $companyNo = trim($this->post['companyNo'] ?? '');
  2018. if ($companyNo !== "") $where[] = ["b.companyNo", 'like', '%' . $companyNo . '%'];
  2019. // $role=$this->checkRole();
  2020. // if(!empty($role['write'])){
  2021. // $where[]=["bo.createrid","in",$role['write']];
  2022. // }
  2023. // $role = $this->checkDataShare();
  2024. // if (!empty($role[DataGroupModel::$type_全部])) $where[] = ['bo.createrid', 'in', $role[DataGroupModel::$type_全部]];
  2025. $role = $this->checkDataShare();
  2026. $hand = resign_hand_user($this->uid, 0);
  2027. if (!empty($role[DataGroupModel::$type_全部])) {
  2028. $arr = array_unique(array_merge($hand, $role[DataGroupModel::$type_全部]));
  2029. $where[] = ['bo.createrid', 'in', $arr];
  2030. }
  2031. $count = Db::name("bargain_order")
  2032. ->alias('bo')
  2033. ->leftJoin('consult_order b', 'b.zxNo=bo.zxNo')
  2034. ->leftJoin('consult_info c', 'c.infoNo=bo.infoNo')
  2035. ->where($where)
  2036. ->count('bo.id');
  2037. $total = ceil($count / $size);
  2038. $page = $page >= $total ? $total : $page;
  2039. $list = Db::name('bargain_order')
  2040. ->alias('bo')
  2041. ->field('bo.*,b.companyNo,b.area,c.num,b.platform_code')
  2042. ->leftJoin('consult_order b', 'b.zxNo=bo.zxNo')
  2043. ->leftJoin('consult_info c', 'c.infoNo=bo.infoNo')
  2044. ->where($where)
  2045. ->page($page, $size)
  2046. ->order('bo.addtime', 'desc')
  2047. ->select()
  2048. ->toArray();
  2049. $all_createrid = array_column($list, 'createrid');
  2050. $item = get_company_name_by_uid($all_createrid);
  2051. $userCommon = \app\admin\common\User::getIns();
  2052. $names = $userCommon->handle('getCodeAndName', ['code' => array_column($list, 'companyNo')]);
  2053. $bidinfos_list = Db::name('consult_bids')
  2054. ->where(['is_del' => 0, 'bidNo' => array_column($list, 'bidsNo')])
  2055. ->column('*', 'bidNo');
  2056. $brand = Db::name("brand")
  2057. ->where(["id" =>array_column($bidinfos_list,'brand_id')])
  2058. ->column('brand_name', 'id');
  2059. $cat = Db::name("cat")
  2060. ->where(["id" => array_column($bidinfos_list,'cat_id')])
  2061. ->column('order_rate', 'id');
  2062. $unit = Db::name("unit")
  2063. ->where(["id" => array_column($bidinfos_list,'unit_id')])
  2064. ->column('unit', 'id');
  2065. $data = [];
  2066. foreach ($list as $value) {
  2067. $value['companyName'] = $names['data'][$value['companyNo']] ?? '';
  2068. // $bidinfos = Db::name("consult_bids")->where([["bidNo","=",$value['bidsNo']],["is_del","=",0]])->find();
  2069. $bidinfos = $bidinfos_list[$value['bidsNo']];
  2070. $value['spuCode'] = isset($bidinfos['spuCode']) ? $bidinfos['spuCode'] : "";
  2071. $value['good_name'] = isset($bidinfos['good_name']) ? $bidinfos['good_name'] : "";
  2072. $value['good_img'] = isset($bidinfos['good_img']) ? $bidinfos['good_img'] : "";
  2073. $value['brand_id'] = isset($bidinfos['brand_id']) ? $bidinfos['brand_id'] : "";
  2074. if ($bidinfos['brand_id'] != 0) {
  2075. $value['brand_id'] = $bidinfos['brand_id'];
  2076. // $brand=Db::name("brand")->where(["id"=>$bidinfos['brand_id']])->find();
  2077. $value["brand_name"] = $brand[$value['brand_id']] ?? '';//isset($brand['brand_name'])?$brand['brand_name']:"";
  2078. } else {
  2079. $value["brand_name"] = "";
  2080. $value["brand_id"] = "";
  2081. }
  2082. // $catinfo = Db::name("cat")->where(["id"=>$bidinfos['cat_id']])->find();
  2083. $value['can'] = isset($bidinfos['cat_id']) && $bidinfos['cat_id'] != 0 ? made($bidinfos['cat_id']) : [];
  2084. // $unit =Db::name("unit")->where(["id"=>$bidinfos['unit_id']])->find();
  2085. $value['unit'] = $unit[$bidinfos['unit_id']] ?? '';//isset($unit['unit'])?$unit['unit']:'';
  2086. // $bidinfoe = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
  2087. // $budget = $cat[$bidinfos['cat_id']] ?? 0;//isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
  2088. $budget = get_budget($bidinfos['cat_id'],$value['companyNo']??'',$value['platform_code']??0);
  2089. $value['budget'] = $budget;
  2090. $god = [
  2091. "metal_id" => $bidinfos['metal_id'],
  2092. "weight" => $bidinfos["good_weight"],
  2093. "demo_fee" => $bidinfos["demo_fee"],
  2094. "delivery_fee" => $bidinfos["delivery_fee"],
  2095. "open_fee" => $bidinfos["open_fee"],
  2096. "packing_fee" => $bidinfos["pakge_fee"],
  2097. "mark_fee" => $bidinfos["mark_fee"],
  2098. "nake_fee" => $bidinfos["nake_fee"],
  2099. "cert_fee" => $bidinfos["cert_fee"],
  2100. "cost_fee" => $bidinfos["cost_fee"],
  2101. "num" => $value["num"],
  2102. ];
  2103. // if($bidinfos['is_gold_price']==1){
  2104. // $price = GoldPrice($god, $budget/100);
  2105. // }else{
  2106. // $price = GoodPrice($god, $budget/100);
  2107. // }
  2108. $value['metal_name'] = isset($bidinfos['metal_id']) && $bidinfos['metal_id'] != 0 ? $this->noble[$bidinfos['metal_id']] : "";
  2109. $value['sale_price'] = round($bidinfos['origin_price'], 2);
  2110. $value['cost_before_price'] = round($bidinfos['origin_cost_fee'], 2);
  2111. $value['specinfo'] = isset($bidinfos['specinfo']) && $bidinfos['specinfo'] != "" ? json_decode($bidinfos['specinfo'], true) : [];
  2112. $value['company_name'] = $item[$value['createrid']] ?? '';
  2113. //是否具有编辑权限
  2114. $value['is_allow_update'] = 0;
  2115. if (in_array($this->roleid, [1, 33]) || in_array($value['createrid'], $role[DataGroupModel::$type_可编辑])) $value['is_allow_update'] = 1;
  2116. $data[] = $value;
  2117. }
  2118. return app_show(0, "获取成功", ["count" => $count, "list" => $data]);
  2119. }
  2120. //招标工作台
  2121. public function crontablist(){
  2122. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  2123. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  2124. $where=[['a.is_del',"=",0],['b.is_del',"=",0]];
  2125. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  2126. if ($zxNo !== "") {
  2127. $where[] = ['a.zxNo','=',$zxNo];
  2128. }
  2129. $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
  2130. if ($salesman !== "") {
  2131. //$where["salesman"] =Db::Raw("like '%$salesman%'");
  2132. $where[]= ["b.salesman",'like',"%$salesman%"];
  2133. }
  2134. $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : "";
  2135. if ($cpName !== "") {
  2136. //$where["cpName"]= Db::Raw("like '%$cpName%'");
  2137. $where[]= ["a.good_Name",'like',"%$cpName%"];
  2138. }
  2139. $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
  2140. if ($khNo !== "") {
  2141. // $where['khNo'] = $khNo;
  2142. $where[]= ["b.khNo",'like',"%$khNo%"];
  2143. }
  2144. $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
  2145. if ($start !="") {
  2146. //$where = ["zxtime"=>Db::raw(">= '{$start}'")];
  2147. $where[]= ["a.addtime",'>=',$start];
  2148. }
  2149. $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
  2150. if($end !=""){
  2151. $where[]= ["a.addtime",'<=',$end];
  2152. }
  2153. $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
  2154. if ($status !== "") {
  2155. $where[]= ["a.status",'=',$status];
  2156. }
  2157. $userCommon=\app\admin\common\User::getIns();
  2158. $supplierNo = trim($this->post['supplierNo'] ?? '');
  2159. if ($supplierNo != '') {
  2160. //如果筛选供应商,不查看同一家业务公司的数据
  2161. $relaComArr = $userCommon->handle("hqInfo", ["code" => $supplierNo]);
  2162. if ($relaComArr['data']['relation_code'] ?? '' != '') $where[] = ['b.companyNo', '<>', $relaComArr['data']['relation_code']];
  2163. }
  2164. //查看非本公司的竞价单
  2165. $relaComNo = isset($this->post['relaComNo']) && $this->post['relaComNo'] != "" ? trim($this->post['relaComNo']) : "";
  2166. if ($relaComNo != "") {
  2167. if ($this->level == 3) {
  2168. $relaComArr = $userCommon->handle("hqInfo", ["code" => $relaComNo]);
  2169. $where[] = ['b.companyNo', '<>', $relaComArr['data']['relation_code'] ?? ''];
  2170. }
  2171. }
  2172. $count = Db::name('consult_info')
  2173. ->alias("a")
  2174. ->leftJoin("consult_order b","a.zxNo=b.zxNo")
  2175. ->leftJoin("platform c","c.id=b.platform_code")
  2176. ->where($where)
  2177. ->count();
  2178. $total = ceil($count / $size);
  2179. $page = $page >= $total ? $total : $page;
  2180. $list =Db::name('consult_info')
  2181. ->alias("a")
  2182. ->leftJoin("consult_order b","a.zxNo=b.zxNo")
  2183. ->leftJoin("platform c","c.id=b.platform_code")
  2184. ->where($where)
  2185. ->page($page,$size)
  2186. ->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")
  2187. ->select()
  2188. ->toArray();
  2189. $data=[];
  2190. $brand = Db::name('brand')
  2191. ->whereIn('id',array_column($list,'brand_id'))
  2192. ->column('brand_name','id');
  2193. $names = $userCommon->handle('getCodeAndName',['code'=>array_unique(array_merge(array_column($list,'khNo'),array_column($list,'companyNo')))]);
  2194. foreach ($list as $value){
  2195. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  2196. $budget = get_budget((int)$value['cat_id'], $value['companyNo'], (int)$value['platform_id']);
  2197. $value['original_price']=sprintf("%.2f",$value['budget_price']* (1 -$budget));
  2198. $value['brand_name']= $brand[$value['brand_id']]??'';//isset($brand['brand_name']) && $brand['brand_name']!='' ? $brand['brand_name']:"";
  2199. $value['khname'] = $value['companyName'] = "";
  2200. $value['specinfo']=isset($value['specinfo'])&&$value['specinfo']!=""? json_decode($value['specinfo'],true):[];
  2201. if($value['khNo']!==""){
  2202. $value['khname']= $names['data'][$value['khNo']]??'';//isset($kh['companyName'])?$kh['companyName']:"";
  2203. }
  2204. if($value['companyNo']!='') $value['companyName'] = $names['data'][$value['companyNo']]??'';
  2205. $consult =Db::name("consult_bids")
  2206. ->where(["infoNo"=>$value['infoNo'],"createrid"=>$this->uid,"is_del"=>0])
  2207. ->find();
  2208. $consults =Db::name("consult_bids")
  2209. ->where(["infoNo"=>$value['infoNo'],"is_del"=>0])
  2210. ->find();
  2211. $value['is_feed'] =$consult==false?0:1;
  2212. $value['is_all_feed'] =$consults==false?0:1;
  2213. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  2214. $data[]=$value;
  2215. }
  2216. return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
  2217. }
  2218. //复制上面的bidlist方法,只更改排序方式
  2219. public function bidlistCopy()
  2220. {
  2221. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) : "1";
  2222. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) : "10";
  2223. $where = [['cb.is_del', "=", 0]];//不要'取消转单'状态下的数据
  2224. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  2225. if ($zxNo !== "") $where[] = ['cb.zxNo', 'like', '%' . $zxNo . '%'];
  2226. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  2227. if ($infoNo !== "") $where[] = ['cb.infoNo', 'like', '%' . $infoNo . '%'];
  2228. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
  2229. if ($bidNo !== "") $where[] = ['cb.bidNo', 'like', '%' . $bidNo . '%'];
  2230. $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
  2231. if ($pgNo !== "") {
  2232. $bidinfo = Db::name("consult_info")->where([["pgNo", "=", $pgNo], ["is_del", "=", 0]])->column("infoNo");
  2233. $where[] = ['cb.infoNo', 'in', $bidinfo];
  2234. }
  2235. $bargain_status = isset($this->post['bargain_status']) && $this->post['bargain_status'] !== "" ? intval($this->post['bargain_status']) : "";
  2236. if ($bargain_status !== "") {
  2237. $bidinfo = Db::name("consult_info")->where([["bargain_status", "=", $bargain_status], ["is_del", "=", 0]])->column("infoNo");
  2238. $where[] = ['cb.infoNo', 'in', $bidinfo];
  2239. }
  2240. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  2241. if ($projectNo !== "") {
  2242. $zxlist = Db::name("consult_order")->where(["projectNo" => $projectNo, "is_del" => 0, "is_project" => 1])->column("zxNo");
  2243. $where[] = ['cb.zxNo', 'in', $zxlist];
  2244. }
  2245. $is_own = isset($this->post['is_own']) ? intval($this->post['is_own']) : "0";
  2246. if ($is_own == 1) {
  2247. // $token = isset($this->post['token']) ? trim($this->post['token']) : "";
  2248. // if ($token == "") return error_show(101, 'token不能为空');
  2249. // $apply_id = GetUserInfo($token);
  2250. // if (empty($apply_id) || $apply_id['code'] != 0) return error_show(1002, "申请人数据不存在");
  2251. $rm = $this->uid;//isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
  2252. $where[] = ['cb.createrid', "=", $rm];
  2253. }
  2254. $company_name = isset($this->post['company_name']) && $this->post['company_name'] !== "" ? trim($this->post['company_name']) : "";
  2255. if ($company_name !== "") $where[] = ["cb.createrid", 'in', get_company_item_user_by_name($company_name)];
  2256. $good_name = isset($this->post['good_name']) && $this->post['good_name'] !== "" ? trim($this->post['good_name']) : "";
  2257. if ($good_name !== "") $where[] = ["cb.good_name", 'like', '%' . $good_name . '%'];
  2258. // $supplierName = isset($this->post['supplierName']) && $this->post['supplierName'] !== "" ? trim($this->post['supplierName']) : "";
  2259. // if ($supplierName !== "") $where[] = ["s.name", 'like', '%' . $supplierName . '%'];
  2260. $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo'] !== "" ? trim($this->post['supplierNo']) : "";
  2261. if ($supplierNo !== "") $where[] = ["cb.supplierNo", '=', $supplierNo];
  2262. $relaComNo = isset($this->post['relaComNo']) && $this->post['relaComNo'] !== "" ? trim($this->post['relaComNo']) : "";
  2263. if ($relaComNo !== "") $where[] = ["d.companyNo", '=', $relaComNo];
  2264. $companyNo = $this->post['companyNo']??'';
  2265. if($companyNo!='') $where[]=['d.companyNo','like','%' .$this->post['companyNo']. '%'];
  2266. //Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
  2267. $count = Db::name('consult_bids')
  2268. ->alias('cb')
  2269. ->leftJoin("consult_info c", "c.infoNo=cb.infoNo")
  2270. ->leftJoin("consult_order d", "d.zxNo=c.zxNo")
  2271. // ->leftJoin('supplier s', 's.code=cb.supplierNo')
  2272. ->where($where)
  2273. ->count();
  2274. $total = ceil($count / $size);
  2275. $page = $page >= $total ? $total : $page;
  2276. $list = Db::name('consult_bids')
  2277. ->alias('cb')
  2278. ->field('cb.*,d.companyNo,d.platform_code,d.area')
  2279. ->leftJoin("consult_info c", "c.infoNo=cb.infoNo")
  2280. ->leftJoin("consult_order d", "d.zxNo=c.zxNo")
  2281. // ->leftJoin('supplier s', 's.code=cb.supplierNo')
  2282. ->where($where)
  2283. ->page($page, $size)
  2284. ->order('cb.addtime', 'desc')
  2285. ->select()
  2286. ->toArray();
  2287. $data = [];
  2288. $user= \app\admin\common\User::getIns();
  2289. $supplier_temp =$user->handle("getCodeAndName",["code"=>array_unique(array_merge(array_column($list,"supplierNo"),array_column($list,"companyNo")))]);
  2290. // if($supplier_temp['code']!=0 || empty($supplier_temp['data']) ) throw new Exception('该供应商不存在');
  2291. $supplier=$supplier_temp['data']??[];
  2292. $unit=Db::name('unit')
  2293. ->where(['id'=>array_column($list,'unit_id'),'is_del'=>0])
  2294. ->column('unit','id');
  2295. $brand=Db::name('brand')
  2296. ->where(['id'=>array_column($list,'brand_id'),'is_del'=>0])
  2297. ->column('brand_name','id');
  2298. $tmp_cat = [];
  2299. foreach ($list as $value) {
  2300. if(!isset($tmp_cat[$value['cat_id']])) $tmp_cat[$value['cat_id']] =made($value['cat_id']);
  2301. // $catinfo = Db::name("cat")->where(["id" => $value['cat_id']])->find();
  2302. $value['can'] = $tmp_cat[$value['cat_id']]??[];//isset($value['cat_id']) && $value['cat_id'] != 0 ? made($value['cat_id']) : [];
  2303. // $unit = Db::name("unit")->where(["id" => $value['unit_id']])->find();
  2304. $value['unit'] = $unit[$value['unit_id']]??'';//isset($unit['unit']) ? $unit['unit'] : '';
  2305. // $supplier = Db::name("supplier")->where(["code" => $value['supplierNo']])->find();
  2306. $value['supplierName'] = isset($supplier[$value['supplierNo']]) ? $supplier[$value['supplierNo']] : "";
  2307. $value['companyName'] = $supplier[$value['companyNo']]??'';
  2308. // if ($value['brand_id'] != 0) {
  2309. // $brand = Db::name("brand")->where(["id" => $value['brand_id']])->find();
  2310. $value["brand_name"] = $brand[$value['brand_id']] ?? '';//isset($brand['brand_name']) ? $brand['brand_name'] : "";
  2311. // } else {
  2312. // $value["brand_name"] = "";
  2313. // $value["brand_id"] = "";
  2314. // }
  2315. $bidinfo = Db::name("consult_info")->where(["infoNo" => $value["infoNo"]])->find();
  2316. // $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate'] : 0;
  2317. $budget = get_budget((int)$value['cat_id'], $value['companyNo'], (int)$value['platform_code']);
  2318. $god = [
  2319. "metal_id" => $value['metal_id'],
  2320. "weight" => $value["good_weight"],
  2321. "demo_fee" => $value["demo_fee"],
  2322. "delivery_fee" => $value["delivery_fee"],
  2323. "open_fee" => $value["open_fee"],
  2324. "packing_fee" => $value["pakge_fee"],
  2325. "mark_fee" => $value["mark_fee"],
  2326. "nake_fee" => $value["nake_fee"],
  2327. "cert_fee" => $value["cert_fee"],
  2328. "cost_fee" => $value["sale_cost_fee"]!=$value["origin_cost_fee"] ? $value["sale_cost_fee"] : $value["cost_fee"],
  2329. "num" => $bidinfo["num"],
  2330. ];
  2331. if ($value['is_gold_price'] == 1) {
  2332. $price = GoldPrice($god, $budget / 100);
  2333. $value['sale_price'] = round($price, 2);
  2334. }
  2335. $value['cost_fee'] = $value['origin_cost_fee'];
  2336. $value['specinfo'] = json_decode($value['specinfo'], true);
  2337. $value['metal_name'] = isset($value['metal_id']) && $value['metal_id'] != 0 ? $this->noble[$value['metal_id']] : "";
  2338. $value['bargain_status'] = $bidinfo['bargain_status'];
  2339. //reject驳回原因,status==5表示驳回
  2340. $value['reject'] = [];
  2341. if ($value['status'] >= 5) {
  2342. $value['reject'] = Db::name('bargain_order')
  2343. ->field('id,remark,status')
  2344. ->where(['infoNo' => $infoNo, 'bidsNo' => $value['bidNo']])
  2345. ->whereIn('status', 2)->order("id desc")
  2346. ->find();
  2347. }
  2348. //产地
  2349. $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
  2350. if ($value['delivery_place'] != "") {
  2351. list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $value['delivery_place']);
  2352. }
  2353. $value['delivery_place_cn'] = GetAddr(json_encode($place));
  2354. $place = ["provice_code" => "", "city_code" => "", "area_code" => ""];
  2355. if ($value['origin_place'] != "") {
  2356. list($place['provice_code'], $place['city_code'], $place['area_code']) = explode(",", $value['origin_place']);
  2357. }
  2358. $value['origin_addr'] = GetAddr(json_encode($place));
  2359. // if($value['origin_place']!=''){
  2360. // $code = explode(",",$value['origin_place']);
  2361. // $temp=[];
  2362. // $temp['provice_code']=isset($code[0])?$code[0]:"";
  2363. // $temp['city_code']=isset($code[1])?$code[1]:"";
  2364. // $temp['area_code']=isset($code[2])?$code[2]:"";
  2365. // $addr= GetAddr(json_encode($temp));
  2366. // $value['origin_addr'] = $addr;
  2367. // }
  2368. $value['company_name'] = $item[$value['createrid']]??'';
  2369. $data[] = $value;
  2370. }
  2371. unset($tmp_cat);
  2372. unset($list);
  2373. return app_show(0, "获取成功", ['count' => $count, 'list' => $data]);
  2374. }
  2375. /**复制数据
  2376. * @return \think\response\Json|void
  2377. * @throws \think\db\exception\DataNotFoundException
  2378. * @throws \think\db\exception\DbException
  2379. * @throws \think\db\exception\ModelNotFoundException
  2380. */
  2381. public function zxcopy(){
  2382. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  2383. if($infoNo==""){
  2384. return error_show(1004,"参数infoNo不能为空");
  2385. }
  2386. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  2387. if($zxinfo==false){
  2388. return error_show(1004,"未找到信息数据");
  2389. }
  2390. $zxorder = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo']])->value("is_project",0);
  2391. if($zxorder==1)return error_show(1003,"项目类型咨询单不可进行此项复制");
  2392. $zxinfo['status']=0;
  2393. $zxinfo['infoNo']=makeNo("IF");
  2394. $zxinfo['id']=null;
  2395. $zxinfo['bargain_status']=0;
  2396. $zxinfo['updatetime']=date("Y-m-d H:i:s");
  2397. $zxinfo['addtime']=date("Y-m-d H:i:s");
  2398. $copy=Db::name("consult_info")->insert($zxinfo,true);
  2399. if($copy==false)return error_show(1004,"咨询数据复制失败");
  2400. return app_show(0,"咨询数据复制成功",["infoNo"=>$zxinfo['infoNo']]);
  2401. }
  2402. /**修改编辑复制数据
  2403. * @return \think\response\Json|void
  2404. * @throws \think\db\exception\DataNotFoundException
  2405. * @throws \think\db\exception\DbException
  2406. * @throws \think\db\exception\ModelNotFoundException
  2407. */
  2408. public function zxCopyEdit(){
  2409. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  2410. if($infoNo==""){
  2411. return error_show(1004,"参数infoNo不能为空");
  2412. }
  2413. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  2414. if($zxinfo==false){
  2415. return error_show(1004,"未找到信息数据");
  2416. }
  2417. $temp_project = Db::name('consult_order')->field('id,projectNo,khNo,companyNo,area')->where(['zxNo'=>$zxinfo['zxNo'], 'is_del'=>0])->find();
  2418. $area = isset($this->post['area']) && $this->post['area'] !=="" ? trim($this->post['area']) : $temp_project['area'];
  2419. if($area==='')return error_show(1002,"客户区域不能为空");
  2420. $enclosure_file =isset($this->post['enclosure_file'])&&$this->post['enclosure_file']!=""?trim($this->post['enclosure_file']):$zxinfo['enclosure_file'];
  2421. $good_name= isset($this->post['good_name'])&&$this->post['good_name']!=""?trim($this->post['good_name']):"";
  2422. if($good_name==""){
  2423. return error_show(1003,"参数good_name不能为空");
  2424. }
  2425. $good_img= isset($this->post['good_img'])&&$this->post['good_img']!=""?trim($this->post['good_img']):"";
  2426. if($good_img==""){
  2427. return error_show(1003,"参数good_img不能为空");
  2428. }
  2429. $cat_id= isset($this->post['cat_id'])&&$this->post['cat_id']!=""?intval($this->post['cat_id']):"";
  2430. if($cat_id==""){
  2431. return error_show(1003,"参数cat_id不能为空");
  2432. }
  2433. $unit= isset($this->post['unit'])&&$this->post['unit']!=""?trim($this->post['unit']):"";
  2434. if($unit==""){
  2435. return error_show(1003,"参数unit不能为空");
  2436. }
  2437. $brand_id= isset($this->post['brand_id'])&&$this->post['brand_id']!==""?intval($this->post['brand_id']):"0";
  2438. $arrival_time= isset($this->post['arrival_time'])&&$this->post['arrival_time']!=""?$this->post['arrival_time']:"";
  2439. if($arrival_time==""){
  2440. return error_show(1003,"参数arrival_time不能为空");
  2441. }
  2442. $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
  2443. if($specin==""){
  2444. return error_show(1003,"参数specinfo不能为空");
  2445. }
  2446. $cost_desc= isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""?trim($this->post['cost_desc']):"";
  2447. // if($cost_desc==""){
  2448. // return error_show(1003,"参数cost_desc不能为空");
  2449. // }
  2450. $is_addrs= isset($this->post['is_addrs'])&&$this->post['is_addrs']!==""?intval($this->post['is_addrs']):"";
  2451. if($is_addrs===""){
  2452. return error_show(1003,"参数is_addrs不能为空");
  2453. }
  2454. $is_custom= isset($this->post['is_custom'])&&$this->post['is_custom']!==""?trim($this->post['is_custom']):"";
  2455. if($is_custom===""){
  2456. return error_show(1003,"参数is_custom不能为空");
  2457. }
  2458. $metal_id= isset($this->post['metal_id'])&&$this->post['metal_id']!==""?intval($this->post['metal_id']):"";
  2459. if($metal_id===""){
  2460. return error_show(1003,"参数metal_id不能为空");
  2461. }
  2462. $config = isset($this->post['config'])&& $this->post['config']!=""?trim($this->post['config']):"";
  2463. $other_config = isset($this->post['other_config'])&& $this->post['other_config']!=""?trim($this->post['other_config']):"";
  2464. $specs_weight = isset($this->post['specs_weight'])&& $this->post['specs_weight']!==""?floatval($this->post['specs_weight']):"";
  2465. $gold_price = isset($this->post['gold_price'])&& $this->post['gold_price']!==""?floatval($this->post['gold_price']):"";
  2466. $is_gold_price = isset($this->post['is_gold_price'])&& $this->post['is_gold_price']!==""?intval($this->post['is_gold_price']):"0";
  2467. $budget_price = isset($this->post['budget_price'])&& $this->post['budget_price']!==""?floatval($this->post['budget_price']):"";
  2468. $total_weight = isset($this->post['total_weight'])&& $this->post['total_weight']!==""?floatval($this->post['total_weight']):"";
  2469. $num = isset($this->post['num'])&& $this->post['num']!==""?intval($this->post['num']):"";
  2470. if($num===""){
  2471. return error_show(1003,"参数num不能为空");
  2472. }
  2473. if($budget_price===""){
  2474. return error_show(1003,"参数budget_price不能为空");
  2475. }
  2476. $pgNo = isset($this->post['pgNo'])&& $this->post['pgNo']!="" ? trim($this->post['pgNo']):"";
  2477. $use_desc = isset($this->post['use_desc'])&& $this->post['use_desc']!="" ? trim($this->post['use_desc']):"";
  2478. $remark = isset($this->post['remark'])&& $this->post['remark']!="" ? trim($this->post['remark']):"";
  2479. if($remark==""){
  2480. return error_show(1003,"参数remark不能为空");
  2481. }
  2482. $endtime = isset($this->post['endtime'])&& $this->post['endtime']!="" ? trim($this->post['endtime']):"";
  2483. if($endtime==""){
  2484. return error_show(1003,"参数endtime不能为空");
  2485. }
  2486. if($metal_id!=0){
  2487. if($config==""){
  2488. return error_show(1003,"参数config不能为空");
  2489. }
  2490. if($other_config==""){
  2491. return error_show(1003,"参数other_config不能为空");
  2492. }
  2493. if($specs_weight===""){
  2494. return error_show(1003,"参数specs_weight不能为空");
  2495. }
  2496. if($gold_price===""){
  2497. return error_show(1003,"参数gold_price不能为空");
  2498. }
  2499. }
  2500. $specinfo=[];
  2501. foreach ($specin as $v){
  2502. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  2503. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  2504. $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
  2505. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
  2506. $specinfo[]=$v;
  2507. }
  2508. Db::startTrans();
  2509. try{
  2510. $info=[
  2511. "good_name"=>$good_name,
  2512. "good_img"=>$good_img,
  2513. "cat_id"=>$cat_id,
  2514. "unit"=>$unit,
  2515. "brand_id"=>$brand_id,
  2516. "arrival_time"=>$arrival_time,
  2517. "specinfo"=>json_encode($specinfo),
  2518. "cost_desc"=>$cost_desc,
  2519. "is_addrs"=>$is_addrs,
  2520. "is_custom"=>$is_custom,
  2521. "metal_id"=>$metal_id,
  2522. "config"=>$config,
  2523. "other_config"=>$other_config,
  2524. "specs_weight"=>$specs_weight===""?0:$specs_weight,
  2525. "gold_price"=>$gold_price===""? 0 : $gold_price,
  2526. "is_gold_price"=>$is_gold_price===""?0:$is_gold_price,
  2527. "total_weight"=>$total_weight===""? $num*$specs_weight :$total_weight,
  2528. "budget_price"=>$budget_price,
  2529. "num"=>$num,
  2530. "pgNo"=>$pgNo,
  2531. "use_desc"=>$use_desc,
  2532. "remark"=>$remark,
  2533. "bargain_num"=>$zxinfo['bargain_num']+1,
  2534. "status"=>1,
  2535. "is_del"=>0,
  2536. "updatetime"=>date("Y-m-d H:i:s"),
  2537. 'bargain_status'=>1,
  2538. 'enclosure_file'=>$enclosure_file
  2539. ];
  2540. $up = Db::name("consult_info")->where($zxinfo)->update($info);
  2541. if($up){
  2542. //操作记录
  2543. ActionLog::logAdd(['id'=>$this->uid,'nickname'=>$this->uname], [
  2544. "order_code" => $infoNo,//咨询单详情编号
  2545. "status" => 0,//这里的status是之前的值
  2546. "action_remark" => '',//备注
  2547. "action_type" => "edit"//新建create,编辑edit,更改状态status
  2548. ], "ZXD", 1, $this->post);
  2549. //更新consule_order记录
  2550. $op = Db::name('consult_order')->where('zxNo',$zxinfo['zxNo'])->update(['endtime'=>$endtime,'area'=>$area, 'updatetime'=>date('Y-m-d H:i:s')]);
  2551. if($op==false)throw new \Exception("咨询单结束时间更新失败");
  2552. //维护台账记录
  2553. $insert_standing_book_data=[
  2554. 'standBookNo'=>makeNo('IO'),
  2555. 'infoNo'=>$infoNo,
  2556. 'addtime' => date('Y-m-d H:i:s'),
  2557. 'updatetime' => date('Y-m-d H:i:s')
  2558. ];
  2559. if(!empty($temp_project)){
  2560. $insert_standing_book_data['companyNo']=$temp_project['companyNo'];
  2561. $insert_standing_book_data['customer_code']=$temp_project['khNo'];
  2562. }
  2563. Db::name('standing_book')->insert($insert_standing_book_data);
  2564. Db::commit();
  2565. return app_show(0,"咨询修改成功",["infoNo"=>$infoNo]);
  2566. }
  2567. }catch (\Exception $e){
  2568. Db::rollback();
  2569. return error_show(1004,$e->getMessage());
  2570. }
  2571. }
  2572. }