Consult.php 132 KB

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