Consult.php 93 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\model\ActionLog;
  4. use app\admin\model\ProcessOrder;
  5. use think\App;
  6. use think\facade\Db;
  7. use think\facade\Validate;
  8. //咨询单
  9. class Consult extends Base
  10. {
  11. public $noble=[];
  12. public function __construct(App $app)
  13. {
  14. parent::__construct($app);
  15. $this->noble =\think\facade\Config::get("noble");
  16. }
  17. public function conlist(){
  18. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  19. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  20. $where=[['a.is_del',"=",0],['b.is_del',"=",0]];
  21. $infoNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  22. if ($infoNo !== "") {
  23. $where[] = ['a.infoNo','=',$infoNo];
  24. }
  25. $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
  26. if ($salesman !== "") {
  27. //$where["salesman"] =Db::Raw("like '%$salesman%'");
  28. $where[]= ["b.salesman",'like',"%$salesman%"];
  29. }
  30. $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : "";
  31. if ($cpName !== "") {
  32. //$where["cpName"]= Db::Raw("like '%$cpName%'");
  33. $where[]= ["a.good_Name",'like',"%$cpName%"];
  34. }
  35. $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
  36. if ($khNo !== "") {
  37. // $where['khNo'] = $khNo;
  38. $where[]= ["b.khNo",'like',"%$khNo%"];
  39. }
  40. $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !== "" ? trim($this->post['companyNo']) : "";
  41. if ($companyNo !== "") {
  42. // $where['khNo'] = $khNo;
  43. $where[]= ["b.companyNo",'like',"%$companyNo%"];
  44. }
  45. $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
  46. if ($start !="") {
  47. //$where = ["zxtime"=>Db::raw(">= '{$start}'")];
  48. $where[]= ["a.addtime",'>=',$start];
  49. }
  50. $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
  51. if($end !=""){
  52. $where[]= ["a.addtime",'<=',$end];
  53. }
  54. $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
  55. if ($status !== "") {
  56. $where[]= ["a.status",'=',$status];
  57. }
  58. $count = Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)
  59. ->count();
  60. $total = ceil($count / $size);
  61. $page = $page >= $total ? $total : $page;
  62. $list =Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)->page($page,$size)
  63. ->field("a.*,b.createrid,b.creater,b.is_project,b.projectNo,b.khNo,b.endtime,b.platform_code,b.saleid,b.salesman,b.depart")->order("a.id desc")->select();
  64. $data=[];
  65. foreach ($list as $value){
  66. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  67. $value['specinfo']=isset($value['specinfo'])&&$value['specinfo']!=""? json_decode($value['specinfo'],
  68. true):[];
  69. $brand = Db::name("brand")->where(['id'=>$value['brand_id']])->find();
  70. $value['brand_name']= isset($brand['brand_name']) && $brand['brand_name']!='' ? $brand['brand_name']:"";
  71. $value['khname']="";
  72. if($value['khNo']!==""){
  73. $kh=Db::name("customer_info")->where(['companyNo'=>$value['khNo']])->find();
  74. $value['khname']= isset($kh['companyName'])?$kh['companyName']:"";
  75. }
  76. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  77. $data[]=$value;
  78. }
  79. return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
  80. }
  81. public function info(){
  82. $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) : "";
  83. if($id==""){
  84. return error_show(1002,"咨询单编号不能为空");
  85. }
  86. $fo = Db::name('consult')->where(['id'=>$id,'is_del'=>0])->find();
  87. $in= isset($fo['cat_id']) && $fo['cat_id'] !=0 ? made($fo['cat_id']):[];
  88. $fo['can']=$in;
  89. if(empty($fo)){
  90. return error_show(1002,"未找到咨询单编号");
  91. }else{
  92. return app_show(0,"获取成功",$fo);
  93. }
  94. }
  95. public function del(){
  96. $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']) : "";
  97. $de = Db::name('consult')->where(['id'=>$id,'is_del'=>0])->find();
  98. if($de==false){
  99. return error_show(1002,'咨询单信息未找到');
  100. }
  101. $dell= Db::name('consult')->update(['id'=>$id,'is_del'=>1,'updatetime'=>date("Y-m-d H:i:s")]);
  102. if($dell){
  103. return error_show(0,"删除成功");
  104. }else
  105. return error_show(1002,"删除失败");
  106. }
  107. public function create(){
  108. $is_project= isset($this->post['is_project']) && $this->post['is_project'] !=="" ? intval($this->post['is_project']) : "";
  109. if($is_project===""){
  110. return error_show(1002,"参数is_project不能为空");
  111. }
  112. if($is_project==1){
  113. $projectNo= isset($this->post['projectNo']) && $this->post['projectNo'] !=="" ? trim($this->post['projectNo']) : "";
  114. if($projectNo===""){
  115. return error_show(1002,"参数projectNo不能为空");
  116. }
  117. }
  118. $khNo = isset($this->post['khNo']) && $this->post['khNo'] !=="" ? trim($this->post['khNo']) : "";
  119. if($khNo===""){
  120. return error_show(1002,"参数khNo不能为空");
  121. }
  122. $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !=="" ? trim($this->post['companyNo']) : "";
  123. if($companyNo===""){
  124. return error_show(1002,"参数companyNo不能为空");
  125. }
  126. $endtime = isset($this->post['endtime']) && $this->post['endtime'] !=="" ? $this->post['endtime'] : "";
  127. if($endtime===""){
  128. return error_show(1002,"参数endtime不能为空");
  129. }
  130. $platform_code = isset($this->post['platform_code']) && $this->post['platform_code'] !=="" ? trim($this->post['platform_code']) :
  131. "";
  132. if($platform_code===""){
  133. return error_show(1002,"参数platform_code不能为空");
  134. }
  135. $ladder = isset($this->post['ladder'])&&!empty($this->post['ladder']) ? $this->post['ladder']:"";
  136. if($ladder==""){
  137. return error_show(1005,"参数ladder不能为空");
  138. }
  139. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  140. if($token==''){
  141. return error_show(105,"参数token不能为空");
  142. }
  143. $user =GetUserInfo($token);
  144. if(empty($user)||$user['code']!=0){
  145. return error_show(102,"用户数据不存在");
  146. }
  147. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  148. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  149. $depart= Db::name("depart_user")->where(["uid"=>$createrid,"status"=>1,"is_del"=>0])->find();
  150. $zxNo=makeNo("ZX");
  151. Db::startTrans();
  152. try{
  153. $data=[
  154. "zxNo"=>$zxNo,
  155. "createrid"=>$createrid,
  156. "creater"=>$creater,
  157. "is_project"=>$is_project,
  158. "projectNo"=>isset($projectNo) ? $projectNo:"",
  159. "khNo"=>$khNo,
  160. "companyNo"=>$companyNo,
  161. "endtime"=>$endtime,
  162. "salesman"=>$creater,
  163. "platform_code"=>$platform_code,
  164. "saleid"=>$createrid,
  165. "depart"=>isset($depart['itemid'])?$depart['itemid']:0,
  166. "status"=>0,
  167. "is_del"=>0,
  168. "addtime"=>date("Y-m-d H:i:s"),
  169. "updatetime"=>date("Y-m-d H:i:s"),
  170. ];
  171. $zx = Db::name("consult_order")->insert($data);
  172. if($zx){
  173. foreach ($ladder as $value){
  174. $infoNo=makeNo("IF");
  175. $specinfo=[];
  176. if(isset($value['specinfo']) &&!empty($value['specinfo'])){
  177. foreach ($value["specinfo"] as $v){
  178. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  179. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  180. $v['spec_name']=isset($spec['spec_name'])? $spec['spec_name']:"";
  181. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"" ;
  182. $specinfo[]=$v;
  183. }
  184. }
  185. $info=[
  186. "infoNo"=>$infoNo,
  187. "zxNo"=>$zxNo,
  188. "spuCode"=>"",
  189. "good_name"=>$value['good_name'],
  190. "good_img"=>$value['good_img'],
  191. "cat_id"=>$value['cat_id'],
  192. "unit"=>$value['unit'],
  193. "brand_id"=>$value['brand_id'],
  194. "arrival_time"=>$value['arrival_time'],
  195. "specinfo"=>empty($specinfo)?"" : json_encode($specinfo),
  196. "cost_desc" => isset($value['cost_desc']) ? $value['cost_desc'] : '',
  197. "is_addrs"=>$value['is_addrs'],
  198. "is_custom"=>$value['is_custom'],
  199. "metal_id"=>$value['metal_id'],
  200. "config"=>isset($value['config'])?$value['config']:"",
  201. "other_config"=>isset($value['other_config'])?$value['other_config']:"",
  202. "specs_weight"=>isset($value['specs_weight'])?$value['specs_weight']:"0",
  203. "gold_price"=>isset($value['gold_price'])?$value['gold_price']:"0",
  204. "is_gold_price"=>isset($value['is_gold_price'])?$value['is_gold_price']:"0",
  205. "total_weight"=>isset($value['total_weight'])?$value['total_weight']:"0",
  206. "budget_price"=>$value['budget_price'],
  207. "num"=>$value['num'],
  208. "pgNo"=>isset($value['pgNo'])&&$value['pgNo']!==""?trim($value['pgNo']):"",
  209. "use_desc"=>$value['use_desc'],
  210. "remark"=>$value['remark'],
  211. "status"=>1,
  212. "is_del"=>0,
  213. "addtime"=>date("Y-m-d H:i:s"),
  214. "updatetime"=>date("Y-m-d H:i:s"),
  215. 'enclosure_file'=>isset($value['enclosure_file'])?$value['enclosure_file']:'',
  216. ];
  217. $up = Db::name("consult_info")->insert($info);
  218. if(!$up){
  219. Db::rollback();
  220. return error_show(1004,'添加失败');
  221. }else{
  222. //修改状态,添加待办
  223. ActionLog::logAdd($this->post['token'], [
  224. "order_code" => $infoNo,//咨询单详情编号
  225. "status" => 1,//这里的status是之前的值
  226. "action_remark" => '',//备注
  227. "action_type" => "create"//新建create,编辑edit,更改状态status
  228. ], "ZXD", 1, $info);
  229. ProcessOrder::AddProcess($this->post['token'], [
  230. "order_type" => 'ZXD',
  231. "order_code" => $infoNo,//咨询单详情编号
  232. "order_id" => 0,
  233. "order_status" => 1
  234. ]);
  235. }
  236. }
  237. $stn = ["order_code"=>$zxNo,"status"=>1,"action_remark"=>'',"action_type"=>"create"];
  238. ActionLog::logAdd($this->post['token'],$stn,"ZXD",2,$info);
  239. $process=["order_code"=>$zxNo,"order_id"=>Db::name("consult_order")->getLastInsID(),"order_status"=>1,"order_type"=>'ZXD'];
  240. ProcessOrder::AddProcess($this->post['token'],$process);
  241. Db::commit();
  242. return app_show(0,"新建成功",["zxNo"=>$zxNo]);
  243. }else{
  244. Db::rollback();
  245. return error_show(1004,"新建失败");
  246. }
  247. }catch (\Exception $e){
  248. Db::rollback();
  249. return error_show(1003,$e->getMessage());
  250. }
  251. }
  252. public function zxinfo(){
  253. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  254. if($infoNo==""){
  255. return error_show(1004,"参数infoNo不能为空");
  256. }
  257. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  258. if($zxinfo==false){
  259. return error_show(1004,"未找到信息数据");
  260. }
  261. $zxorder = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
  262. if($zxorder==false){
  263. return error_show(1004,"未找到咨询信息数据");
  264. }
  265. $cat =Db::name("cat")->where(["id"=>$zxinfo['cat_id']])->find();
  266. $budget = isset($cat['order_rate']) ? $cat['order_rate']:0;
  267. $zxinfo['can']= isset($zxinfo['cat_id']) && $zxinfo['cat_id'] !=0 ? made($zxinfo['cat_id'],[]):[];
  268. $zxinfo['khname']="";
  269. $zxinfo['original_price']=sprintf("%.2f",$zxinfo['budget_price']* (1 -$budget/100));
  270. $zxinfo['khNo']="";
  271. $zxinfo['brand_id']=$zxinfo['brand_id']==0 ?"":$zxinfo['brand_id'];
  272. $zxinfo['brand']="";
  273. $zxinfo['companyNo']=isset($zxorder['companyNo'])?$zxorder['companyNo']:"";
  274. $zxinfo['projectNo']=isset($zxorder['projectNo'])?$zxorder['projectNo']:"";
  275. $zxinfo['is_project']=isset($zxorder['is_project'])?$zxorder['is_project']:"";
  276. $zxinfo['company']="";
  277. $zxinfo['endtime']=isset($zxorder['endtime'])?$zxorder['endtime']:"";
  278. $zxinfo['platform_code'] =isset($zxorder['platform_code'])?$zxorder['platform_code']:"";
  279. $zxinfo['salesman'] =isset($zxorder['salesman'])?$zxorder['salesman']:"";
  280. $zxinfo['saleid'] =isset($zxorder['saleid'])?$zxorder['saleid']:"";
  281. $zxinfo['depart'] =isset($zxorder['depart'])?$zxorder['depart']:"";
  282. $zxinfo['project_name']="";
  283. $zxinfo['budget_total']="";
  284. $zxinfo['departinfo']=[];
  285. $zxinfo['unit_name']="";
  286. $zxinfo['metal_name']=isset($zxinfo['metal_id'])&& $zxinfo['metal_id']!=0?$this->noble[$zxinfo['metal_id']]:"";
  287. $zxinfo['specinfo']=json_decode($zxinfo['specinfo'],true);
  288. if($zxorder['khNo']!==""){
  289. $kh=Db::name("customer_info")->where(['companyNo'=>$zxorder['khNo']])->find();
  290. $zxinfo['khname']= isset($kh['companyName'])?$kh['companyName']:"";
  291. $zxinfo['khNo']= $zxorder['khNo'];
  292. }
  293. if($zxinfo['unit']!==""){
  294. $unit=Db::name("unit")->where(['id'=>$zxinfo['unit']])->find();
  295. $zxinfo['unit_name']= isset($unit['unit'])?$unit['unit']:"";
  296. }
  297. if($zxinfo['brand_id']!==""){
  298. $unit=Db::name("brand")->where(['id'=>$zxinfo['brand_id']])->find();
  299. $zxinfo['brand']= isset($unit['brand_name'])?$unit['brand_name']:"";
  300. }
  301. if($zxorder['companyNo']!==""){
  302. $kh=Db::name("business")->where(['companyNo'=>$zxorder['companyNo']])->find();
  303. $zxinfo['company']= isset($kh['company'])?$kh['company']:"";
  304. }
  305. if($zxorder['is_project']==1 && $zxorder['projectNo']!==""){
  306. $project = Db::name("project")->where(["projectNo"=>$zxorder['projectNo'],"is_del"=>0])->find();
  307. $zxinfo['project_name']=isset($project['project_name'])?$project['project_name']:"";
  308. $zxinfo['budget_total']=isset($project['budget_total'])?$project['budget_total']:"";
  309. $zxinfo['project_use_desc']=isset($project['use_desc'])?$project['use_desc']:"";
  310. $projectinfo = Db::name("project_info")->where(["pgNo"=>$zxinfo['pgNo']])->find();
  311. $zxinfo['pgNo'] = isset($projectinfo['pgNo']) ? $projectinfo['pgNo']:"";
  312. }
  313. if($zxorder['depart']>0){
  314. $zxinfo['departinfo']=GetPart($zxorder['depart']);
  315. }
  316. if($zxorder['platform_code']>0){
  317. $palt=Db::name("platform")->where(["id"=>$zxorder['platform_code']])->find();
  318. $zxinfo['platform_name']=isset($palt['platform_name'])?$palt['platform_name']:"";
  319. }
  320. return app_show(0,"获取成功",$zxinfo);
  321. }
  322. public function zxedit(){
  323. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  324. if($infoNo==""){
  325. return error_show(1004,"参数infoNo不能为空");
  326. }
  327. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  328. if($zxinfo==false){
  329. return error_show(1004,"未找到信息数据");
  330. }
  331. $enclosure_file =isset($this->post['enclosure_file'])&&$this->post['enclosure_file']!=""?trim($this->post['enclosure_file']):$zxinfo['enclosure_file'];
  332. $good_name= isset($this->post['good_name'])&&$this->post['good_name']!=""?trim($this->post['good_name']):"";
  333. if($good_name==""){
  334. return error_show(1003,"参数good_name不能为空");
  335. }
  336. $good_img= isset($this->post['good_img'])&&$this->post['good_img']!=""?trim($this->post['good_img']):"";
  337. if($good_img==""){
  338. return error_show(1003,"参数good_img不能为空");
  339. }
  340. $cat_id= isset($this->post['cat_id'])&&$this->post['cat_id']!=""?intval($this->post['cat_id']):"";
  341. if($cat_id==""){
  342. return error_show(1003,"参数cat_id不能为空");
  343. }
  344. $unit= isset($this->post['unit'])&&$this->post['unit']!=""?trim($this->post['unit']):"";
  345. if($unit==""){
  346. return error_show(1003,"参数unit不能为空");
  347. }
  348. $brand_id= isset($this->post['brand_id'])&&$this->post['brand_id']!==""?intval($this->post['brand_id']):"0";
  349. $arrival_time= isset($this->post['arrival_time'])&&$this->post['arrival_time']!=""?$this->post['arrival_time']:"";
  350. if($arrival_time==""){
  351. return error_show(1003,"参数arrival_time不能为空");
  352. }
  353. $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
  354. if($specin==""){
  355. return error_show(1003,"参数specinfo不能为空");
  356. }
  357. $cost_desc= isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""?trim($this->post['cost_desc']):"";
  358. // if($cost_desc==""){
  359. // return error_show(1003,"参数cost_desc不能为空");
  360. // }
  361. $is_addrs= isset($this->post['is_addrs'])&&$this->post['is_addrs']!==""?intval($this->post['is_addrs']):"";
  362. if($is_addrs===""){
  363. return error_show(1003,"参数is_addrs不能为空");
  364. }
  365. $is_custom= isset($this->post['is_custom'])&&$this->post['is_custom']!==""?trim($this->post['is_custom']):"";
  366. if($is_custom===""){
  367. return error_show(1003,"参数is_custom不能为空");
  368. }
  369. $metal_id= isset($this->post['metal_id'])&&$this->post['metal_id']!==""?intval($this->post['metal_id']):"";
  370. if($metal_id===""){
  371. return error_show(1003,"参数metal_id不能为空");
  372. }
  373. $config = isset($this->post['config'])&& $this->post['config']!=""?trim($this->post['config']):"";
  374. $other_config = isset($this->post['other_config'])&& $this->post['other_config']!=""?trim($this->post['other_config']):"";
  375. $specs_weight = isset($this->post['specs_weight'])&& $this->post['specs_weight']!==""?floatval($this->post['specs_weight']):"";
  376. $gold_price = isset($this->post['gold_price'])&& $this->post['gold_price']!==""?floatval($this->post['gold_price']):"";
  377. $is_gold_price = isset($this->post['is_gold_price'])&& $this->post['is_gold_price']!==""?intval($this->post['is_gold_price']):"0";
  378. $budget_price = isset($this->post['budget_price'])&& $this->post['budget_price']!==""?floatval($this->post['budget_price']):"";
  379. $total_weight = isset($this->post['total_weight'])&& $this->post['total_weight']!==""?floatval($this->post['total_weight']):"";
  380. $num = isset($this->post['num'])&& $this->post['num']!==""?intval($this->post['num']):"";
  381. if($num===""){
  382. return error_show(1003,"参数num不能为空");
  383. }
  384. if($budget_price===""){
  385. return error_show(1003,"参数budget_price不能为空");
  386. }
  387. $pgNo = isset($this->post['pgNo'])&& $this->post['pgNo']!="" ? trim($this->post['pgNo']):"";
  388. $use_desc = isset($this->post['use_desc'])&& $this->post['use_desc']!="" ? trim($this->post['use_desc']):"";
  389. if($use_desc==""){
  390. return error_show(1003,"参数use_desc不能为空");
  391. }
  392. $remark = isset($this->post['remark'])&& $this->post['remark']!="" ? trim($this->post['remark']):"";
  393. if($remark==""){
  394. return error_show(1003,"参数remark不能为空");
  395. }
  396. $endtime = isset($this->post['endtime'])&& $this->post['endtime']!="" ? trim($this->post['endtime']):"";
  397. if($endtime==""){
  398. return error_show(1003,"参数endtime不能为空");
  399. }
  400. if($metal_id!=0){
  401. if($config==""){
  402. return error_show(1003,"参数config不能为空");
  403. }
  404. if($other_config==""){
  405. return error_show(1003,"参数other_config不能为空");
  406. }
  407. if($specs_weight===""){
  408. return error_show(1003,"参数specs_weight不能为空");
  409. }
  410. if($gold_price===""){
  411. return error_show(1003,"参数gold_price不能为空");
  412. }
  413. }
  414. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  415. if($token==''){
  416. return error_show(102,"参数token不能为空");
  417. }
  418. $user =GetUserInfo($token);
  419. if(empty($user)||$user['code']!=0){
  420. return error_show(105,"用户数据不存在");
  421. }
  422. $specinfo=[];
  423. foreach ($specin as $v){
  424. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  425. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  426. $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
  427. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
  428. $specinfo[]=$v;
  429. }
  430. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  431. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  432. $bidlist = Db::name("consult_bids")->where(["infoNo"=>$zxinfo['infoNo'],"is_del"=>0])->select();
  433. Db::startTrans();
  434. try{
  435. $innew =makeNo("IF");
  436. $info=[
  437. "infoNo"=>$innew,
  438. "zxNo"=>$zxinfo['zxNo'],
  439. "spuCode"=>"",
  440. "good_name"=>$good_name,
  441. "good_img"=>$good_img,
  442. "cat_id"=>$cat_id,
  443. "unit"=>$unit,
  444. "brand_id"=>$brand_id,
  445. "arrival_time"=>$arrival_time,
  446. "specinfo"=>json_encode($specinfo),
  447. // "color"=>$color,
  448. // "material"=>$material,
  449. "cost_desc"=>$cost_desc,
  450. "is_addrs"=>$is_addrs,
  451. "is_custom"=>$is_custom,
  452. "metal_id"=>$metal_id,
  453. "config"=>$config,
  454. "other_config"=>$other_config,
  455. "specs_weight"=>$specs_weight===""?0:$specs_weight,
  456. "gold_price"=>$gold_price===""? 0 : $gold_price,
  457. "is_gold_price"=>$is_gold_price===""?0:$is_gold_price,
  458. "total_weight"=>$total_weight===""? $num*$specs_weight :$total_weight,
  459. "budget_price"=>$budget_price,
  460. "num"=>$num,
  461. "pgNo"=>$pgNo,
  462. "use_desc"=>$use_desc,
  463. "remark"=>$remark,
  464. "status"=>1,
  465. "is_del"=>0,
  466. "addtime"=>date("Y-m-d H:i:s"),
  467. "updatetime"=>date("Y-m-d H:i:s"),
  468. 'bargain_status'=>1,
  469. 'enclosure_file'=>$enclosure_file
  470. ];
  471. $up = Db::name("consult_info")->insert($info);
  472. if($up){
  473. //修改状态,添加待办
  474. ActionLog::logAdd($this->post['token'], [
  475. "order_code" => $innew,//咨询单详情编号
  476. "status" => 1,//这里的status是之前的值
  477. "action_remark" => '',//备注
  478. "action_type" => "create"//新建create,编辑edit,更改状态status
  479. ], "ZXD", 1, $info);
  480. ProcessOrder::AddProcess($this->post['token'], [
  481. "order_type" => 'ZXD',
  482. "order_code" => $innew,//咨询单详情编号
  483. "order_id" => 0,
  484. "order_status" => 1
  485. ]);
  486. if (!empty($bidlist)){
  487. foreach ($bidlist as $value){
  488. unset($value['id']);
  489. $value['infoNo']=$innew;
  490. $value['bidNo']=makeNo("BD");
  491. $value['spuCode']=makeNo("SKU");
  492. $value['status'] =0;
  493. $value['updatetime'] =date("Y-m-d H:i:s");
  494. $in = Db::name("consult_bids")->insert($value);
  495. if($in==false){
  496. Db::rollback();
  497. return error_show(1004,"反馈商品新建失败");
  498. }
  499. }
  500. }
  501. $zxinfo["bargain_status"] =1;
  502. $zxinfo["bargain_code"] =$innew;
  503. $zxinfo["updatetime"] =date("Y-m-d H:i:s");
  504. $bar=Db::name("consult_info")->save($zxinfo);
  505. if($bar==false){
  506. Db::rollback();
  507. return error_show(1004,"反馈商品更新失败");
  508. }else{
  509. //修改状态,添加待办
  510. ActionLog::logAdd($this->post['token'], [
  511. "order_code" => $zxinfo['infoNo'],//咨询单详情编号
  512. "status" => $zxinfo['status'],//这里的status是之前的值
  513. "action_remark" => '',//备注
  514. "action_type" => "edit"//新建create,编辑edit,更改状态status
  515. ], "ZXD", $zxinfo['status'], $zxinfo);
  516. // 并没有修改状态
  517. // ProcessOrder::AddProcess($this->post['token'], [
  518. // "order_type" => 'ZXD',
  519. // "order_code" => $zxinfo['infoNo'],//咨询单详情编号
  520. // "order_id" => $zxinfo['id'],
  521. // "order_status" => $zxinfo['status']
  522. // ]);
  523. }
  524. //更新consule_order记录
  525. Db::name('consult_order')->where('zxNo',$zxinfo['zxNo'])->update(['endtime'=>$endtime,'updatetime'=>date('Y-m-d H:i:s')]);
  526. Db::commit();
  527. return app_show(0,"咨询新建成功",["infoNo"=>$innew]);
  528. }
  529. }catch (\Exception $e){
  530. Db::rollback();
  531. return error_show(1004,$e->getMessage());
  532. }
  533. }
  534. //** 发布竞标任务 */
  535. public function bargain(){
  536. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  537. if($infoNo==""){
  538. return error_show(1004,"参数infoNo不能为空");
  539. }
  540. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  541. if($zxinfo==false){
  542. return error_show(1004,"未找到信息数据");
  543. }
  544. $status =isset($this->post['status']) && $this->post['status']!=="" ? intval($this->post['status']):"";
  545. if($status===""){
  546. return error_show(1004,"参数status不能为空");
  547. }
  548. if($status==1&&$zxinfo['status']>1){
  549. $zxinfo['bargain_num']=+1;
  550. }
  551. $old_zxinfo_status = $zxinfo['status'];
  552. $zxinfo['status']=$status;
  553. $zxinfo['updatetime']=date("Y-m-d H:i:s");
  554. $up = Db::name("consult_info")->save($zxinfo);
  555. if($up){
  556. //修改状态,添加待办
  557. ActionLog::logAdd($this->post['token'], [
  558. "order_code" => $zxinfo['infoNo'],//咨询单详情编号
  559. "status" => $old_zxinfo_status,//这里的status是之前的值
  560. "action_remark" => '',//备注
  561. "action_type" => "status"//新建create,编辑edit,更改状态status
  562. ], "ZXD", $zxinfo['status'], $zxinfo);
  563. ProcessOrder::AddProcess($this->post['token'], [
  564. "order_type" => 'ZXD',
  565. "order_code" => $zxinfo['infoNo'],//咨询单详情编号
  566. "order_id" => $zxinfo['id'],
  567. "order_status" => $zxinfo['status']
  568. ]);
  569. return app_show(0,"状态更新成功");
  570. }else{
  571. return error_show(1003,"状态更新失败");
  572. }
  573. }
  574. public function feadback(){
  575. $infoNo= isset($this->post['infoNo'])&&$this->post['infoNo']!=""?trim($this->post['infoNo']):"";
  576. if($infoNo==""){
  577. return error_show(1002,"参数infoNo不能为空");
  578. }
  579. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$infoNo,"is_del"=>0])->find();
  580. if($zxinfo==false){
  581. return error_show(1003,"未找到信息数据");
  582. }
  583. if($zxinfo['status']!=1){
  584. return error_show(1004,"任务未进行");
  585. }
  586. $zx = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
  587. if($zx==false){
  588. return error_show(1003,"未找咨询信息数据");
  589. }
  590. $pname = isset($this->post['pname'])&&$this->post['pname']!=""? trim($this->post['pname']):"";
  591. if($pname==""){
  592. return error_show(1002,"参数pname不能为空");
  593. }
  594. $brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):"";
  595. $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? trim($this->post['cat_id']):"";
  596. if($cat_id==""){
  597. return error_show(1002,"参数cat_id不能为空");
  598. }
  599. $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
  600. if($specin==""){
  601. return error_show(1003,"参数specinfo不能为空");
  602. }
  603. $specinfo=[];
  604. foreach ($specin as $v){
  605. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  606. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  607. $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
  608. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
  609. $specinfo[]=$v;
  610. }
  611. $unit_id = isset($this->post['unit_id'])&&$this->post['unit_id']!=""? intval($this->post['unit_id']):"";
  612. $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""? trim($this->post['cost_desc']):"";
  613. $work_day = isset($this->post['work_day'])&&$this->post['work_day']!=""? intval($this->post['work_day']):"";
  614. $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!=""? intval($this->post['delivery_day']):"";
  615. $good_img = isset($this->post['good_img'])&&$this->post['good_img']!=""? trim($this->post['good_img']):"";
  616. $expire_day = isset($this->post['expire_day'])&&$this->post['expire_day']!=""? intval($this->post['expire_day'])
  617. :"";
  618. $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!=""? trim($this->post['origin_place']):"";
  619. $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
  620. $pay_way = isset($this->post['pay_way'])&&$this->post['pay_way']!=""? intval($this->post['pay_way']):"";
  621. $tax = isset($this->post['tax'])&&$this->post['tax']!=""? trim($this->post['tax']):"";
  622. $send_way = isset($this->post['send_way'])&&$this->post['send_way']!=""? intval($this->post['send_way']):"";
  623. $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!=""? intval($this->post['metal_id']):"";
  624. $is_gold_price = isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!=""? intval($this->post['is_gold_price']):"";
  625. $config = isset($this->post['config'])&&$this->post['config']!=""? $this->post['config']:"";
  626. $other_config = isset($this->post['other_config'])&&$this->post['other_config']!=""? $this->post['other_config']:"";
  627. $weight = isset($this->post['weight'])&&$this->post['weight']!==""? floatval($this->post['weight']):"";
  628. $good_weight = isset($this->post['good_weight'])&&$this->post['good_weight']!==""? floatval($this->post['good_weight']):"";
  629. $demo_fee = isset($this->post['demo_fee'])&&$this->post['demo_fee']!==""? floatval($this->post['demo_fee']):"";
  630. $delivery_fee = isset($this->post['delivery_fee'])&&$this->post['delivery_fee']!==""? floatval($this->post['delivery_fee']):"";
  631. $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!==""? floatval($this->post['open_fee']):"";
  632. $pakge_fee = isset($this->post['pakge_fee'])&&$this->post['pakge_fee']!==""? floatval
  633. ($this->post['pakge_fee']):"";
  634. $nake_fee = isset($this->post['nake_fee'])&&$this->post['nake_fee']!==""? floatval($this->post['nake_fee']):"";
  635. $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!==""? floatval($this->post['mark_fee']):"";
  636. $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!==""? floatval($this->post['cert_fee']):"";
  637. $cost_fee = isset($this->post['cost_fee'])&&$this->post['cost_fee']!==""? floatval($this->post['cost_fee']):"";
  638. if($nake_fee==="" ){
  639. return error_show(1004,"参数nake_fee不能为空");
  640. }
  641. $is_diff = isset($this->post['is_diff'])&&$this->post['is_diff']!==""? intval($this->post['is_diff']):"";
  642. $supply_area = isset($this->post['supply_area'])&&$this->post['supply_area']!==""? intval($this->post['supply_area']):"";
  643. $remark = isset($this->post['remark'])&&$this->post['remark']!=""? trim($this->post['remark']):"";
  644. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  645. if($token==''){
  646. return error_show(1002,"参数token不能为空");
  647. }
  648. $user =GetUserInfo($token);
  649. if(empty($user)||$user['code']!=0){
  650. return error_show(1005,"用户数据不存在");
  651. }
  652. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  653. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  654. $bidNo=makeNo("BD");
  655. $spucode=makeNo("SKU");
  656. $catinfo = Db::name("cat")->where(["id"=>$cat_id])->find();
  657. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:0;
  658. //部分参数的大小校验
  659. $vali = Validate::rule([
  660. 'expire_day|有效时长'=>'require|elt:214748364',
  661. 'delivery_day|物流时长'=>'require|elt:214748364',
  662. 'work_day|生产工期'=>'require|elt:214748364',
  663. 'weight|总重量'=>'require|max:10',
  664. ]);
  665. $temp = [
  666. 'expire_day'=>$expire_day,
  667. 'delivery_day'=>$delivery_day,
  668. 'work_day'=>$work_day,
  669. 'weight'=>$weight,
  670. ];
  671. if(!$vali->check($temp)) return error_show(0,$vali->getError());
  672. if($is_gold_price==1){
  673. $gold = Db::name("gold_price1")->where(["type"=>$metal_id,"is_del"=>0,"status"=>1])->order("addtime desc")
  674. ->find();
  675. $total_fee = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee*
  676. $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  677. $saleprice = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee/(1-$budget)*
  678. $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  679. }else{
  680. $saleprice = $open_fee/$zxinfo['num'] +
  681. $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee/(1-$budget);
  682. $total_fee = $open_fee/$zxinfo['num'] +
  683. $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  684. }
  685. $data=[
  686. "bidNo"=>$bidNo,
  687. "infoNo"=>$infoNo,
  688. "zxNo"=>$zxinfo['zxNo'],
  689. "spuCode"=>$spucode,
  690. "good_name"=>$pname,
  691. "brand_id"=>$brandid,
  692. "cat_id"=>$cat_id,
  693. "specinfo"=>json_encode($specinfo),
  694. "unit_id"=>$unit_id,
  695. "cost_desc"=>$cost_desc,
  696. "work_day"=>$work_day,
  697. "delivery_day"=>$delivery_day,
  698. "good_img"=>$good_img,
  699. "expire_day"=>$expire_day,
  700. "origin_place"=>$origin_place,
  701. "supplierNo"=>$supplierNo,
  702. "pay_way"=>$pay_way,
  703. "tax"=>$tax,
  704. "send_way"=>$send_way,
  705. "metal_id"=>$metal_id,
  706. "is_gold_price"=>$is_gold_price,
  707. "config"=>$config,
  708. "other_config"=>$other_config,
  709. "weight"=>$weight,
  710. "good_weight"=>$good_weight,
  711. "is_diff"=>$is_diff,
  712. "demo_fee"=>$demo_fee,
  713. "delivery_fee"=>$delivery_fee,
  714. "open_fee"=>$open_fee,
  715. "pakge_fee"=>$pakge_fee,
  716. "nake_fee"=>$nake_fee,
  717. "mark_fee"=>$mark_fee,
  718. "cert_fee"=>$cert_fee,
  719. "cost_fee"=>$cost_fee,
  720. "total_fee"=>$total_fee,
  721. "supply_area"=>$supply_area,
  722. "remark"=>$remark,
  723. "sale_price"=>$saleprice,
  724. "origin_price"=>$saleprice,
  725. "createrid"=>$createrid,
  726. "creater"=>$creater,
  727. "status"=>$zxinfo['status']==1 ?1 :2,
  728. "is_del"=>0,
  729. "addtime"=>date("Y-m-d H:i:s"),
  730. "updatetime"=>date("Y-m-d H:i:s")
  731. ];
  732. Db::startTrans();
  733. try{
  734. $insert= Db::name("consult_bids")->insert($data);
  735. if($insert){
  736. // $data=[
  737. // "spuCode"=>$spucode,
  738. // "good_name"=>$pname,
  739. // "brand_id"=>$brandid,
  740. // "good_unit"=>$unit_id,
  741. // "good_type"=>0,
  742. // "moq"=>1,
  743. // "customized"=>$work_day,
  744. // "tax"=>$tax,
  745. // "supplierNo"=>$supplierNo,
  746. // "is_auth"=>0,
  747. // "craft_desc"=>$cost_desc,
  748. // "good_remark"=>$remark,
  749. // "good_img"=>$good_img,
  750. // "good_thumb_img"=>"",
  751. // "good_info_img"=>"",
  752. // "status"=>1,
  753. // "is_del"=>0,
  754. // "createrid"=>$createrid,
  755. // "creater"=>$creater,
  756. // "addtime"=>date("Y-m-d H:i:s"),
  757. // "updatetime"=>date("Y-m-d H:i:s")
  758. // ];
  759. // $good = Db::name("good_zixun")->insert($data);
  760. if($zx['is_project']==1 && $zx['projectNo']!="" && $zxinfo['pgNo']!=""){
  761. $projectinfo =Db::name("project_info")->where(["pgNo"=>$zxinfo["pgNo"],"projectNo"=>$zx['projectNo'],"is_del"=>0])->find();
  762. if($projectinfo==false){
  763. Db::rollback();
  764. return error_show(1006,"未找到项目信息");
  765. }
  766. $temp=[];
  767. $temp['spuCode']=$spucode;
  768. $temp['skuCode']="";
  769. $temp['pgNo']=$zxinfo['pgNo'];
  770. $temp['projectNo']=$zx['projectNo'];
  771. $temp['good_name']=$pname;
  772. $temp['good_type']=$projectinfo['good_type'];
  773. $temp['data_source']=2;
  774. $temp['cat_id']=$cat_id;
  775. $temp['budget_price']=$projectinfo['budget_price'];
  776. $temp['sale_price']=$saleprice;
  777. $temp['origin_price']=$total_fee;
  778. $temp['num']=$zxinfo['num'];
  779. $temp['status']=0;
  780. $temp['is_del']=0;
  781. $temp['creater']=$creater;
  782. $temp['createrid']=$createrid;
  783. $temp['addtime']=date("Y-m-d H:i:s");
  784. $temp['updatetime']=date("Y-m-d H:i:s");
  785. $nu = Db::name("project_feedback")->insert($temp);
  786. if($nu==false){
  787. Db::rollback();
  788. return error_show(1006,"项目反馈失败");
  789. }else{
  790. $old_projectinfo_status = $projectinfo['status'];
  791. $projectinfo['status']=2;
  792. $projectinfo['updatetime']=date("Y-m-d H:i:s");
  793. $up = Db::name("project_info")->save($projectinfo);
  794. if($up){
  795. //修改状态,添加待办,只记录动作
  796. ActionLog::logAdd($this->post['token'], [
  797. "order_code" => $projectinfo['pgNo'],//编码
  798. "status" => $old_projectinfo_status,//这里的status是之前的值
  799. "action_remark" => '',//备注
  800. "action_type" => "status"//新建create,编辑edit,更改状态status
  801. ], "PRO", 2, $projectinfo);
  802. $count = Db::name("project_info")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])
  803. ->count();
  804. if($count==0){
  805. $projetc =Db::name("project")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])->find();
  806. if($projetc!=false){
  807. $proc =Db::name("project")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])->save
  808. (["status"=>2,"updatetime"=>date("Y-m-d H:i:s")]);
  809. if($proc==false){
  810. Db::rollback();
  811. return error_show(1006,"项目反馈失败");
  812. }else{
  813. //修改状态,添加待办
  814. ActionLog::logAdd($this->post['token'], [
  815. "order_code" => $projetc['projectNo'],//项目编码
  816. "status" => 1,//这里的status是之前的值
  817. "action_remark" => '',//备注
  818. "action_type" => "status"//新建create,编辑edit,更改状态status
  819. ], "PRO", 2, $projetc);
  820. ProcessOrder::AddProcess($this->post['token'], [
  821. "order_type" => 'PRO',
  822. "order_code" => $projetc['projectNo'],
  823. "order_id" => $projetc['id'],
  824. "order_status" => 2
  825. ]);
  826. }
  827. }
  828. }
  829. }
  830. }
  831. }
  832. Db::commit();
  833. return app_show(0,"反馈成功",["bidNo"=>$bidNo]);
  834. }else{
  835. Db::rollback();
  836. return error_show(1006,"反馈失败");
  837. }
  838. }catch (\Exception $e){
  839. Db::rollback();
  840. return error_show(1006,$e->getMessage());
  841. }
  842. }
  843. public function feadinfo(){
  844. $bidNo =isset($this->post['bidNo'])&& $this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  845. if($bidNo==""){
  846. return error_show(1004,"参数bidNo不能为空");
  847. }
  848. $info =Db::name("consult_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
  849. if($info==false){
  850. return error_show(1004,"未找到商品数据");
  851. }
  852. $unit =Db::name("unit")->where(["id"=>$info['unit_id']])->find();
  853. $info['unit'] = isset($unit['unit'])?$unit['unit']:'';
  854. $info['cat_info'] = made($info['cat_id'],[]);
  855. $supplier = Db::name("supplier")->where(["code"=>$info['supplierNo']])->find();
  856. $info['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  857. if($info['brand_id']!=0){
  858. $brand=Db::name("brand")->where(["id"=>$info['brand_id']])->find();
  859. $info["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  860. }else{
  861. $info["brand_name"]="";
  862. $info["brand_id"]="";
  863. }
  864. $catinfo = Db::name("cat")->where(["id"=>$info['cat_id']])->find();
  865. $bidinfo = Db::name("consult_info")->where(["infoNo"=>$info["infoNo"]])->find();
  866. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
  867. $god=[
  868. "metal_id"=>$info['metal_id'],
  869. "weight"=>$info["weight"],
  870. "demo_fee"=>$info["demo_fee"],
  871. "delivery_fee"=>$info["delivery_fee"],
  872. "open_fee"=>$info["open_fee"],
  873. "packing_fee"=>$info["pakge_fee"],
  874. "mark_fee"=>$info["mark_fee"],
  875. "nake_fee"=>$info["nake_fee"],
  876. "cert_fee"=>$info["cert_fee"],
  877. "cost_fee"=>$info["cost_fee"],
  878. "num"=>$bidinfo["num"],
  879. ];
  880. if($info['is_gold_price']==1){
  881. $price = GoldPrice($god, $budget/100);
  882. $info['sale_price'] =round($price,2);
  883. }
  884. $info['specinfo'] = json_decode($info['specinfo'],true);
  885. $info['metal_name']=isset($info['metal_id'])&& $info['metal_id']!=0?$this->noble[$info['metal_id']]:"";
  886. $bargain =Db::name("bargain_order")->where(['bidsNo'=>$bidNo,"is_del"=>0])->find();
  887. $info['bargain'] =$bargain;
  888. return app_show(0,"获取成功",$info);
  889. }
  890. public function feededit(){
  891. $bidNo= isset($this->post['bidNo'])&&$this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  892. if($bidNo==""){
  893. return error_show(1002,"参数bidNo不能为空");
  894. }
  895. $bidinfo = Db::name("consult_bids")->where(["bidNo"=>$bidNo,"is_del"=>0])->find();
  896. if($bidinfo==false){
  897. return error_show(1003,"未找到信息数据");
  898. }
  899. if($bidinfo['status']>=5){
  900. return error_show(1004,"咨询单已确认无法修改");
  901. }
  902. $zxinfo = Db::name("consult_info")->where(["infoNo"=>$bidinfo['infoNo'],"is_del"=>0])->find();
  903. if($zxinfo==false){
  904. return error_show(1003,"未找到信息数据");
  905. }
  906. $zx = Db::name("consult_order")->where(["zxNo"=>$zxinfo['zxNo'],"is_del"=>0])->find();
  907. if($zx==false){
  908. return error_show(1003,"未找咨询信息数据");
  909. }
  910. $pname = isset($this->post['pname'])&&$this->post['pname']!=""? trim($this->post['pname']):"";
  911. if($pname==""){
  912. return error_show(1002,"参数pname不能为空");
  913. }
  914. $brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):"";
  915. // if($brandid==""){
  916. // return error_show(1002,"参数brandid不能为空");
  917. // }
  918. $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? trim($this->post['cat_id']):"";
  919. if($cat_id==""){
  920. return error_show(1002,"参数cat_id不能为空");
  921. }
  922. $specin= isset($this->post['specinfo'])&&!empty($this->post['specinfo'])?$this->post['specinfo']:"";
  923. if($specin==""){
  924. return error_show(1003,"参数specinfo不能为空");
  925. }
  926. $specinfo=[];
  927. foreach ($specin as $v){
  928. $spec =Db::name("specs")->where(["id"=>$v['specid']])->find();
  929. $spec_value =Db::name("spec_value")->where(["id"=>$v['spec_value_id']])->find();
  930. $v['spec_name']=isset($spec['spec_name'])?$spec['spec_name']:"";
  931. $v['spec_value_name']=isset($spec_value['spec_value'])?$spec_value['spec_value']:"";
  932. $specinfo[]=$v;
  933. }
  934. $unit_id = isset($this->post['unit_id'])&&$this->post['unit_id']!=""? intval($this->post['unit_id']):"";
  935. $cost_desc = isset($this->post['cost_desc'])&&$this->post['cost_desc']!=""? trim($this->post['cost_desc']):"";
  936. $work_day = isset($this->post['work_day'])&&$this->post['work_day']!=""? intval($this->post['work_day']):"";
  937. $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!=""? intval($this->post['delivery_day']):"";
  938. $good_img = isset($this->post['good_img'])&&$this->post['good_img']!=""? trim($this->post['good_img']):"";
  939. $expire_day = isset($this->post['expire_day'])&&$this->post['expire_day']!=""? intval($this->post['expire_day'])
  940. :"";
  941. $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!=""? trim($this->post['origin_place']):"";
  942. $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
  943. $pay_way = isset($this->post['pay_way'])&&$this->post['pay_way']!=""? intval($this->post['pay_way']):"";
  944. $tax = isset($this->post['tax'])&&$this->post['tax']!=""? trim($this->post['tax']):"";
  945. $send_way = isset($this->post['send_way'])&&$this->post['send_way']!=""? intval($this->post['send_way']):"";
  946. $metal_id = isset($this->post['metal_id'])&&$this->post['metal_id']!=""? intval($this->post['metal_id']):"";
  947. $is_gold_price = isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!=""? intval($this->post['is_gold_price']):"";
  948. $config = isset($this->post['config'])&&$this->post['config']!=""? $this->post['config']:"";
  949. $other_config = isset($this->post['other_config'])&&$this->post['other_config']!=""? $this->post['other_config']:"";
  950. $weight = isset($this->post['weight'])&&$this->post['weight']!=""? floatval($this->post['weight']):"";
  951. $demo_fee = isset($this->post['demo_fee'])&&$this->post['demo_fee']!=""? floatval($this->post['demo_fee']):"";
  952. $delivery_fee = isset($this->post['delivery_fee'])&&$this->post['delivery_fee']!=""? floatval($this->post['delivery_fee']):"";
  953. $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!=""? floatval($this->post['open_fee']):"";
  954. $pakge_fee = isset($this->post['pakge_fee'])&&$this->post['pakge_fee']!=""? floatval($this->post['pakge_fee']):"";
  955. $nake_fee = isset($this->post['nake_fee'])&&$this->post['nake_fee']!==""? floatval($this->post['nake_fee']):"";
  956. if($nake_fee==="" ||$nake_fee==0 ){
  957. return error_show(1004,"参数nake_fee不能为空或零");
  958. }
  959. $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!=""? floatval($this->post['mark_fee']):"";
  960. $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!=""? floatval($this->post['cert_fee']):"";
  961. $cost_fee = isset($this->post['cost_fee'])&&$this->post['cost_fee']!=""? floatval($this->post['cost_fee']):"";
  962. $total_fee = isset($this->post['total_fee'])&&$this->post['total_fee']!=""? floatval($this->post['total_fee']):"";
  963. $is_diff = isset($this->post['is_diff'])&&$this->post['is_diff']!==""? intval($this->post['is_diff']):"";
  964. $supply_area = isset($this->post['supply_area'])&&$this->post['supply_area']!==""? intval($this->post['supply_area']):"";
  965. $remark = isset($this->post['remark'])&&$this->post['remark']!=""? trim($this->post['remark']):"";
  966. $catinfo = Db::name("cat")->where(["id"=>$cat_id])->find();
  967. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:0;
  968. if($is_gold_price==1){
  969. $gold = Db::name("gold_price1")->where(["type"=>$metal_id,"is_del"=>0,"status"=>1])->order("addtime desc")
  970. ->find();
  971. $total_fee = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee*
  972. $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  973. $saleprice = $open_fee/$zxinfo['num'] + $weight* $gold["price"] + $cost_fee/(1-$budget)*
  974. $weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  975. }else{
  976. $saleprice = $open_fee/$zxinfo['num'] +
  977. $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee/(1-$budget);
  978. $total_fee = $open_fee/$zxinfo['num'] +
  979. $cost_fee*$weight+$pakge_fee+$mark_fee+$cert_fee+$nake_fee;
  980. }
  981. Db::startTrans();
  982. try{
  983. $data=[
  984. "good_name"=>$pname,
  985. "brand_id"=>$brandid,
  986. "cat_id"=>$cat_id,
  987. "specinfo"=>json_encode($specinfo),
  988. // "material"=>$material,
  989. "unit_id"=>$unit_id,
  990. "cost_desc"=>$cost_desc,
  991. "work_day"=>$work_day,
  992. "delivery_day"=>$delivery_day,
  993. "good_img"=>$good_img,
  994. "expire_day"=>$expire_day,
  995. "origin_place"=>$origin_place,
  996. "supplierNo"=>$supplierNo,
  997. "pay_way"=>$pay_way,
  998. "tax"=>$tax,
  999. "send_way"=>$send_way,
  1000. "metal_id"=>$metal_id,
  1001. "is_gold_price"=>$is_gold_price,
  1002. "config"=>$config,
  1003. "other_config"=>$other_config,
  1004. "weight"=>$weight,
  1005. "is_diff"=>$is_diff,
  1006. "demo_fee"=>$demo_fee,
  1007. "delivery_fee"=>$delivery_fee,
  1008. "open_fee"=>$open_fee,
  1009. "pakge_fee"=>$pakge_fee,
  1010. "nake_fee"=>$nake_fee,
  1011. "mark_fee"=>$mark_fee,
  1012. "cert_fee"=>$cert_fee,
  1013. "cost_fee"=>$cost_fee,
  1014. "total_fee"=>$total_fee,
  1015. "sale_price"=>$saleprice,
  1016. "supply_area"=>$supply_area,
  1017. "remark"=>$remark,
  1018. "updatetime"=>date("Y-m-d H:i:s")
  1019. ];
  1020. $insert= Db::name("consult_bids")->where($bidinfo)->save($data);
  1021. if($insert){
  1022. if($zx['is_project']==1 && $zx['projectNo']!="" && $zxinfo['pgNo']!=""){
  1023. $projectinfo =Db::name("project_info")->where(["pgNo"=>$zxinfo["pgNo"],"projectNo"=>$zx['projectNo'],"is_del"=>0])->find();
  1024. if($projectinfo==false){
  1025. Db::rollback();
  1026. return error_show(1006,"未找到项目信息");
  1027. }
  1028. $feed = Db::name("project_feedback")->where(["pgNo"=>$zxinfo["pgNo"],"projectNo"=>$zx['projectNo'],"spuCode"=>$bidinfo['spuCode'],"is_del"=>0])->find();
  1029. if($feed==false){
  1030. Db::rollback();
  1031. return error_show(1006,"未找到项目反馈信息");
  1032. }
  1033. $feed['good_name']=$pname;
  1034. $feed['good_type']=$projectinfo['good_type'];
  1035. $feed['cat_id']=$cat_id;
  1036. $feed['sale_price']=$saleprice;
  1037. $feed['origin_price']=$total_fee;
  1038. $feed['updatetime']=date("Y-m-d H:i:s");
  1039. $temp['updatetime']=date("Y-m-d H:i:s");
  1040. $nu = Db::name("project_feedback")->save($feed);
  1041. if($nu==false){
  1042. Db::rollback();
  1043. return error_show(1006,"项目反馈失败");
  1044. }else{
  1045. $old_projectinfo_status = $projectinfo['status'];
  1046. $projectinfo['status']=2;
  1047. $projectinfo['updatetime']=date("Y-m-d H:i:s");
  1048. $up = Db::name("project_info")->save($projectinfo);
  1049. if($up){
  1050. //修改状态,添加待办,只记录动作
  1051. ActionLog::logAdd($this->post['token'], [
  1052. "order_code" => $projectinfo['pgNo'],//编码
  1053. "status" => $old_projectinfo_status,//这里的status是之前的值
  1054. "action_remark" => '',//备注
  1055. "action_type" => "status"//新建create,编辑edit,更改状态status
  1056. ], "PRO", 2, $projectinfo);
  1057. $count = Db::name("project_info")->where(["projectNo"=>$projectinfo['projectNo'],"status"=>1])->count();
  1058. if ($count == 0) {
  1059. //先查询是否存在status==1的项目,有的话再更新,否则跳过
  1060. $project_id = Db::name("project")->where(["projectNo" => $projectinfo['projectNo'], "status" => 1])->value('id', 0);
  1061. if ($project_id) {
  1062. $proc = Db::name("project")->where(["id" => $project_id])->update(["status" => 2, "updatetime" => date("Y-m-d H:i:s")]);
  1063. if ($proc == false) {
  1064. Db::rollback();
  1065. return error_show(1006, "项目反馈失败");
  1066. }else{
  1067. //修改状态,添加待办
  1068. ActionLog::logAdd($this->post['token'], [
  1069. "order_code" => $projectinfo['projectNo'],//项目编码
  1070. "status" => 1,//这里的status是之前的值
  1071. "action_remark" => '',//备注
  1072. "action_type" => "status"//新建create,编辑edit,更改状态status
  1073. ], "PRO", 2, $this->post);
  1074. ProcessOrder::AddProcess($this->post['token'], [
  1075. "order_type" => 'PRO',
  1076. "order_code" => $projectinfo['projectNo'],
  1077. "order_id" => $project_id,
  1078. "order_status" => 2
  1079. ]);
  1080. }
  1081. }
  1082. }
  1083. }
  1084. }
  1085. }
  1086. Db::commit();
  1087. return app_show(0,"编辑成功");
  1088. }else{
  1089. Db::rollback();
  1090. return error_show(1004,"编辑失败");
  1091. }
  1092. }catch (\Exception $e){
  1093. Db::rollback();
  1094. return error_show(1004,$e->getMessage());
  1095. }
  1096. }
  1097. public function bargain_add(){
  1098. $bidNo = isset($this->post['bidNo'])&& $this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  1099. if($bidNo===""){
  1100. return error_show(1004,"参数bidNo不能为空");
  1101. }
  1102. $info =Db::name("consult_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
  1103. if($info==false){
  1104. return error_show(1004,"未找到商品数据");
  1105. }
  1106. $bargain_price = isset($this->post['bargain_price'])&& $this->post['bargain_price']!=""?floatval($this->post['bargain_price']):"";
  1107. if($bargain_price===""){
  1108. return error_show(1004,"参数bargain_price不能为空");
  1109. }
  1110. $bargain_reason = isset($this->post['bargain_reason'])&& $this->post['bargain_reason']!=""?trim($this->post['bargain_reason']):"";
  1111. // if($bargain_reason===""){
  1112. // return error_show(1004,"参数bargain_reason不能为空");
  1113. // }
  1114. $infos =Db::name("consult_info")->where(['infoNo'=>$info['infoNo'],"is_del"=>0])->find();
  1115. if($infos==false){
  1116. return error_show(1004,"未找到商品数据");
  1117. }
  1118. if($infos['status']!=2&&$infos['status']!=3&&$infos['status']!=7){
  1119. return error_show(1004,"咨询单招标未结束或已确认商品");
  1120. }
  1121. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1122. if($token==''){
  1123. return error_show(105,"参数token不能为空");
  1124. }
  1125. $user =GetUserInfo($token);
  1126. if(empty($user)||$user['code']!=0){
  1127. return error_show(1002,"用户数据不存在");
  1128. }
  1129. //新增两个字段
  1130. //议价备注
  1131. $bargain_remark = isset($this->post['bargain_remark']) && $this->post['bargain_remark'] != "" ? trim($this->post['bargain_remark']) : "";
  1132. //议价原因id
  1133. $result_info_id = isset($this->post['result_info_id']) && $this->post['result_info_id'] != "" ? $this->post['result_info_id'] : "";
  1134. if ($result_info_id != '') {
  1135. $temp = Db::name('result_info')->field('id')->where(['result_code' => $result_info_id, 'type' => 7, 'status' => 1, 'is_del' => 0])->find();//type 7议价原因
  1136. if (empty($temp)) return error_show(1004, "议价原因选择不正确");
  1137. }
  1138. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1139. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1140. $bargainNo =makeNo("BA");
  1141. Db::startTrans();//::todo 金价 毛利计算
  1142. try{
  1143. $data=[
  1144. "bidsNo"=>$bidNo,
  1145. "infoNo"=>$info['infoNo'],
  1146. "zxNo"=>$info['zxNo'],
  1147. "bargainNo"=>$bargainNo,
  1148. "bargain_type"=>1,
  1149. "bargain_reason"=>$bargain_reason,
  1150. "sale_price"=>$info['sale_price'],
  1151. "cost_before_price"=>$info['cost_fee'],
  1152. "cost_after_price"=>$info['cost_fee'],
  1153. "before_rate"=>$info['cost_fee'],
  1154. "after_rate"=>$info['cost_fee'],
  1155. "after_price"=>$bargain_price,
  1156. "exam_info"=>"",
  1157. "status"=>1,
  1158. "is_del"=>0,
  1159. "creater"=>$creater,
  1160. "createrid"=>$createrid,
  1161. "addtime"=>date("Y-m-d H:i:s"),
  1162. "updatetime"=>date("Y-m-d H:i:s"),
  1163. 'bargain_remark'=>$bargain_remark,
  1164. 'result_info_id'=>$result_info_id,
  1165. ];
  1166. $int = Db::name("bargain_order")->insert($data);
  1167. if($int){
  1168. $info['status']=3;
  1169. $info['updatetime']=date("Y-m-d H:i:s");
  1170. $up =Db::name("consult_bids")->save($info);
  1171. if($up){
  1172. $old_infos_status = $infos['status'];
  1173. $infos['status']=3;
  1174. $infos['updatetime']=date("Y-m-d H:i:s");
  1175. $ups =Db::name("consult_info")->save($infos);
  1176. if($ups){
  1177. //修改状态,添加待办
  1178. ActionLog::logAdd($this->post['token'], [
  1179. "order_code" => $infos['infoNo'],//咨询单详情编号
  1180. "status" => $old_infos_status,//这里的status是之前的值
  1181. "action_remark" => '',//备注
  1182. "action_type" => "status"//新建create,编辑edit,更改状态status
  1183. ], "ZXD", $infos['status'], $infos);
  1184. ProcessOrder::AddProcess($this->post['token'], [
  1185. "order_type" => 'ZXD',
  1186. "order_code" => $infos['infoNo'],//咨询单详情编号
  1187. "order_id" => $infos['id'],
  1188. "order_status" => $infos['status']
  1189. ]);
  1190. Db::commit();
  1191. return app_show(0,"议价单生成成功",["bargainNo"=>$bargainNo]);
  1192. }
  1193. }
  1194. }
  1195. Db::rollback();
  1196. return error_show(1004,"议价单新建失败");
  1197. }catch (\Exception $e){
  1198. Db::rollback();
  1199. return error_show(1004,$e->getMessage());
  1200. }
  1201. }
  1202. //选择商品
  1203. public function bids_check(){
  1204. $bidNo = isset($this->post['bidNo'])&& $this->post['bidNo']!=""?trim($this->post['bidNo']):"";
  1205. if($bidNo===""){
  1206. return error_show(1004,"参数bidNo不能为空");
  1207. }
  1208. $info =Db::name("consult_bids")->where(['bidNo'=>$bidNo,"is_del"=>0])->find();
  1209. if($info==false){
  1210. return error_show(1004,"未找到商品数据");
  1211. }
  1212. $infos =Db::name("consult_info")->where(['infoNo'=>$info['infoNo'],"is_del"=>0])->find();
  1213. if($infos==false){
  1214. return error_show(1004,"未找到商品数据");
  1215. }
  1216. if($infos['status']!=2&&$infos['status']!=3&&$infos['status']!=7){
  1217. return error_show(1004,"咨询单招标未结束或已确认商品");
  1218. }
  1219. Db::startTrans();
  1220. try {
  1221. $info['status']=6;
  1222. $info['updatetime']=date("Y-m-d H:i:s");
  1223. $bids = Db::name("consult_bids")->save($info);
  1224. if($bids){
  1225. $old_infos_status = $infos['status'];
  1226. $infos['status']=4;
  1227. $infos['updatetime']=date("Y-m-d H:i:s");
  1228. $se = Db::name("consult_info")->save($infos);
  1229. if($se){
  1230. //修改状态,添加待办
  1231. ActionLog::logAdd($this->post['token'], [
  1232. "order_code" => $infos['infoNo'],//咨询单详情编号
  1233. "status" => $old_infos_status,//这里的status是之前的值
  1234. "action_remark" => '',//备注
  1235. "action_type" => "status"//新建create,编辑edit,更改状态status
  1236. ], "ZXD", $infos['status'], $infos);
  1237. ProcessOrder::AddProcess($this->post['token'], [
  1238. "order_type" => 'ZXD',
  1239. "order_code" => $infos['infoNo'],//咨询单详情编号
  1240. "order_id" => $infos['id'],
  1241. "order_status" => $infos['status']
  1242. ]);
  1243. Db::commit();
  1244. return app_show(0,"商品确定成功");
  1245. }
  1246. }
  1247. Db::rollback();
  1248. return error_show(1004,"商品确认失败");
  1249. }catch (\Exception $e){
  1250. Db::rollback();
  1251. return error_show(1004,$e->getMessage());
  1252. }
  1253. }
  1254. //议价审核
  1255. public function bargain_status(){
  1256. $bargainNo = isset($this->post['bargainNo'])&& $this->post['bargainNo']!=""?trim($this->post['bargainNo']):"";
  1257. if($bargainNo===""){
  1258. return error_show(1004,"参数bargainNo不能为空");
  1259. }
  1260. $info =Db::name("bargain_order")->where(['bargainNo'=>$bargainNo,"is_del"=>0])->find();
  1261. if($info==false){
  1262. return error_show(1004,"未找到议价数据");
  1263. }
  1264. $bids=Db::name("consult_bids")->where(["bidNo"=>$info["bidsNo"],"is_del"=>0])->find();
  1265. if($bids==false){
  1266. return error_show(1004,"未找到商品数据");
  1267. }
  1268. $coninfo=Db::name("consult_info")->where(["infoNo"=>$bids["infoNo"],"is_del"=>0])->find();
  1269. if($coninfo==false){
  1270. return error_show(1004,"未找到咨询单数据");
  1271. }
  1272. $status = isset($this->post['status'])&& $this->post['status']!=='' ? intval($this->post['status']):"";
  1273. if($status==''){
  1274. return error_show(1005,"参数status不能为空");
  1275. }
  1276. $remark = isset($this->post['remark'])&& $this->post['remark']!=""?trim($this->post['remark']):"";
  1277. // if($remark==""){
  1278. // return error_show(1004,"参数remark不能为空");
  1279. // }
  1280. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1281. if($token==''){
  1282. return error_show(105,"参数token不能为空");
  1283. }
  1284. $user =GetUserInfo($token);
  1285. if(empty($user)||$user['code']!=0){
  1286. return error_show(1002,"用户数据不存在");
  1287. }
  1288. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1289. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1290. Db::startTrans();
  1291. try{
  1292. $examinfo = isset($info['exam_info'])&&$info['exam_info']!="" ? json_decode($info['exam_info'],true):[];
  1293. $examinfo[]=["status"=>$status,"remark"=>$remark,"createrid"=>$createrid,"creater"=>$creater];
  1294. $info['status'] =$status;
  1295. $info['remark'] =$remark;
  1296. $info['exam_info']=json_encode($examinfo) ;
  1297. $info['updatetime'] =date("Y-m-d H:i:s");
  1298. $up =Db::name("bargain_order")->save($info);
  1299. if($up){
  1300. if($status==4||$status==5||$status==6||$status==7){
  1301. $bids['status']=5;
  1302. if($status==4){
  1303. $bids['sale_price']=$info['after_price'];
  1304. }
  1305. $bids['updatetime']=date("Y-m-d H:i:s");
  1306. $up =Db::name("consult_bids")->save($bids);
  1307. if($up==false){
  1308. Db::rollback();
  1309. return error_show(1004,"数据更新失败");
  1310. }
  1311. }
  1312. Db::commit();
  1313. return app_show(0,"更新成功");
  1314. }
  1315. }catch (\Exception $e){
  1316. Db::rollback();
  1317. return error_show(1004,$e->getMessage());
  1318. }
  1319. }
  1320. public function bargain_info(){
  1321. $bargainNo = isset($this->post['bargainNo'])&& $this->post['bargainNo']!=""?trim($this->post['bargainNo']):"";
  1322. if($bargainNo===""){
  1323. return error_show(1004,"参数bargainNo不能为空");
  1324. }
  1325. $info =Db::name("bargain_order")->where(['bargainNo'=>$bargainNo,"is_del"=>0])->find();
  1326. if($info==false){
  1327. return error_show(1004,"未找到议价数据");
  1328. }
  1329. $bidinfos = Db::name("consult_bids")->where([["bidNo","=",$info['bidsNo']],["is_del","=",0]])->find();
  1330. if($bidinfos==false){
  1331. return error_show(1004,"未找到商品数据");
  1332. }
  1333. $consultinfos = Db::name("consult_info")->where([["infoNo","=",$bidinfos['infoNo']],["is_del","=",0]])
  1334. ->find();
  1335. if($consultinfos==false){
  1336. return error_show(1004,"未找到咨询商品数据");
  1337. }
  1338. $info['spuCode'] = isset($bidinfos['spuCode'])?$bidinfos['spuCode']:"";
  1339. $info['good_name'] = isset($bidinfos['good_name'])?$bidinfos['good_name']:"";
  1340. $info['good_img'] = isset($bidinfos['good_img'])?$bidinfos['good_img']:"";
  1341. $info['brand_id'] = isset($bidinfos['brand_id'])?$bidinfos['brand_id']:"";
  1342. $info['good_num'] = isset($consultinfos['num'])?$consultinfos['num']:"";
  1343. $info['exam_info'] = isset($info['exam_info'])&&$info['exam_info']!=""?json_encode($info['exam_info']):"";
  1344. if($bidinfos['brand_id']!=0){
  1345. $info['brand_id'] = $bidinfos['brand_id'];
  1346. $brand=Db::name("brand")->where(["id"=>$bidinfos['brand_id']])->find();
  1347. $info["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1348. }else{
  1349. $info["brand_name"]="";
  1350. $info["brand_id"]="";
  1351. }
  1352. $catinfo = Db::name("cat")->where(["id"=>$bidinfos['cat_id']])->find();
  1353. $info['can']= isset($bidinfos['cat_id']) && $bidinfos['cat_id'] !=0 ? made($bidinfos['cat_id']):[];
  1354. $unit =Db::name("unit")->where(["id"=>$bidinfos['unit_id']])->find();
  1355. $info['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1356. $bidinfoe = Db::name("consult_info")->where(["infoNo"=>$info["infoNo"]])->find();
  1357. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
  1358. $info['budget'] =$budget;
  1359. $god=[
  1360. "metal_id"=>$bidinfos['metal_id'],
  1361. "weight"=>$bidinfos["weight"],
  1362. "demo_fee"=>$bidinfos["demo_fee"],
  1363. "delivery_fee"=>$bidinfos["delivery_fee"],
  1364. "open_fee"=>$bidinfos["open_fee"],
  1365. "packing_fee"=>$bidinfos["pakge_fee"],
  1366. "mark_fee"=>$bidinfos["mark_fee"],
  1367. "nake_fee"=>$bidinfos["nake_fee"],
  1368. "cert_fee"=>$bidinfos["cert_fee"],
  1369. "cost_fee"=>$bidinfos["cost_fee"],
  1370. "num"=>$bidinfoe["num"],
  1371. ];
  1372. $info['gold_price']=0;
  1373. if($bidinfos['is_gold_price']==1 &&$bidinfos['metal_id']>0){
  1374. $gold = Db::name("gold_price1")->where(["type"=>$bidinfos["metal_id"],"is_del"=>0,"status"=>1])->order("addtime desc")
  1375. ->find();
  1376. $info['gold_price'] =$gold['price'];
  1377. }
  1378. $info['cost_desc'] =$bidinfos['cost_desc'];
  1379. $info['work_day'] =$bidinfos['work_day'];
  1380. $info['delivery_day'] =$bidinfos['delivery_day'];
  1381. $info['expire_day'] =$bidinfos['expire_day'];
  1382. $info['origin_place'] =$bidinfos['origin_place'];
  1383. $info['origin_addr'] ="";
  1384. if($bidinfos['origin_place']!=''){
  1385. $code = explode(",",$bidinfos['origin_place']);
  1386. $temp=[];
  1387. $temp['provice_code']=isset($code[0])?$code[0]:"";
  1388. $temp['city_code']=isset($code[1])?$code[1]:"";
  1389. $temp['area_code']=isset($code[2])?$code[2]:"";
  1390. $addr= GetAddr(json_encode($temp));
  1391. $info['origin_addr'] = $addr;
  1392. }
  1393. $info['supplierNo'] =$bidinfos['supplierNo'];
  1394. $supplier = Db::name("supplier")->where(["code"=>$info['supplierNo']])->find();
  1395. $info['supplier_name'] = isset($supplier['name'])?$supplier['name']:"";
  1396. $info['pay_way'] =$bidinfos['pay_way'];
  1397. $info['tax'] =$bidinfos['tax'];
  1398. $info['send_way'] =$bidinfos['send_way'];
  1399. $info['metal_id'] =$bidinfos['metal_id'];
  1400. $info['is_gold_price'] =$bidinfos['is_gold_price'];
  1401. $info['config'] =$bidinfos['config'];
  1402. $info['other_config'] =$bidinfos['other_config'];
  1403. $info['weight'] =$bidinfos['weight'];
  1404. $info['is_diff'] =$bidinfos['is_diff'];
  1405. $info['demo_fee'] =$bidinfos['demo_fee'];
  1406. $info['delivery_fee'] =$bidinfos['delivery_fee'];
  1407. $info['open_fee'] =$bidinfos['open_fee'];
  1408. $info['pakge_fee'] =$bidinfos['pakge_fee'];
  1409. $info['nake_fee'] =$bidinfos['nake_fee'];
  1410. $info['mark_fee'] =$bidinfos['mark_fee'];
  1411. $info['cert_fee'] =$bidinfos['cert_fee'];
  1412. $info['cost_fee'] =$bidinfos['cost_fee'];
  1413. $info['total_fee'] =$bidinfos['total_fee'];
  1414. $info['supply_area'] =$bidinfos['supply_area'];
  1415. $info['remark'] =$bidinfos['remark'];
  1416. $info['is_addrs'] =$consultinfos['is_addrs'];
  1417. $info['is_custom'] =$consultinfos['is_custom'];
  1418. $info['metal_name']=isset($bidinfos['metal_id'])&& $bidinfos['metal_id']!=0?$this->noble[$bidinfos['metal_id']]:"";
  1419. $info['sale_price'] =round($bidinfos['sale_price'],2);
  1420. $info['specinfo'] = isset($bidinfos['specinfo'])&&$bidinfos['specinfo']!=""?json_decode($bidinfos['specinfo'],true):[];
  1421. //获取议价原因
  1422. if ($info['result_info_id'] != 0) {
  1423. $info['result_info'] = Db::name('result_info')->where(['result_code' => $info['result_info_id'], 'type' => 7, 'status' => 1, 'is_del' => 0])->value('result');
  1424. } else {
  1425. $info['result_info'] = '';
  1426. }
  1427. return app_show(0,"获取成功",$info);
  1428. }
  1429. public function bidlist(){
  1430. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  1431. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  1432. $where=[['is_del',"=",0]];
  1433. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1434. if ($zxNo !== "") {
  1435. $where[] = ['zxNo','=',$zxNo];
  1436. }
  1437. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  1438. if ($infoNo !== "") {
  1439. $where[] = ['infoNo','=',$infoNo];
  1440. }
  1441. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
  1442. if ($bidNo !== "") {
  1443. $where[] = ['bidNo','=',$bidNo];
  1444. }
  1445. $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
  1446. if ($pgNo !== "") {
  1447. $bidinfo = Db::name("consult_info")->where([["pgNo","=",$pgNo],["is_del","=",0]])->column("infoNo");
  1448. $where[] = ['infoNo','in',$bidinfo];
  1449. }
  1450. $bargain_status = isset($this->post['bargain_status']) && $this->post['bargain_status'] !== "" ? intval($this->post['bargain_status']) : "";
  1451. if ($bargain_status !== "") {
  1452. $bidinfo = Db::name("consult_info")->where([["bargain_status","=",$bargain_status],["is_del","=",0]])->column("infoNo");
  1453. $where[] = ['infoNo','in',$bidinfo];
  1454. }
  1455. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  1456. if ($projectNo !== "") {
  1457. $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column
  1458. ("zxNo");
  1459. $where[] = ['zxNo','in',$zxlist];
  1460. }
  1461. $is_own = isset($this->post['is_own']) ? intval($this->post['is_own']) : "0";
  1462. if($is_own==1){
  1463. $token = isset($this->post['token']) ? trim($this->post['token']) : "";
  1464. if($token==""){
  1465. return error_show(101,'token不能为空');
  1466. }
  1467. $apply_id =GetUserInfo($token);
  1468. if(empty($apply_id)||$apply_id['code']!=0){
  1469. return error_show(1002,"申请人数据不存在");
  1470. }
  1471. $rm= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
  1472. $where[]=['createrid',"=",$rm];
  1473. }
  1474. $count = Db::name('consult_bids')->where($where)->count();
  1475. $total = ceil($count / $size);
  1476. $page = $page >= $total ? $total : $page;
  1477. $list =Db::name('consult_bids')->where($where)->page($page,$size)->select()->toArray();
  1478. $data=[];
  1479. foreach ($list as $value){
  1480. $catinfo = Db::name("cat")->where(["id"=>$value['cat_id']])->find();
  1481. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  1482. $unit =Db::name("unit")->where(["id"=>$value['unit_id']])->find();
  1483. $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1484. $supplier = Db::name("supplier")->where(["code"=>$value['supplierNo']])->find();
  1485. $value['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  1486. if($value['brand_id']!=0){
  1487. $brand=Db::name("brand")->where(["id"=>$value['brand_id']])->find();
  1488. $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1489. }else{
  1490. $value["brand_name"]="";
  1491. $value["brand_id"]="";
  1492. }
  1493. $bidinfo = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
  1494. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
  1495. $god=[
  1496. "metal_id"=>$value['metal_id'],
  1497. "weight"=>$value["weight"],
  1498. "demo_fee"=>$value["demo_fee"],
  1499. "delivery_fee"=>$value["delivery_fee"],
  1500. "open_fee"=>$value["open_fee"],
  1501. "packing_fee"=>$value["pakge_fee"],
  1502. "mark_fee"=>$value["mark_fee"],
  1503. "nake_fee"=>$value["nake_fee"],
  1504. "cert_fee"=>$value["cert_fee"],
  1505. "cost_fee"=>$value["cost_fee"],
  1506. "num"=>$bidinfo["num"],
  1507. ];
  1508. if($value['is_gold_price']==1){
  1509. $price = GoldPrice($god, $budget/100);
  1510. $value['sale_price'] = round($price,2);
  1511. }
  1512. $value['specinfo'] = json_decode($value['specinfo'],true);
  1513. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  1514. $value['bargain_status']=$bidinfo['bargain_status'];
  1515. //reject驳回原因,status==5表示驳回
  1516. $value['reject']=[];
  1517. if ($value['status'] == 5) {
  1518. $value['reject'] = Db::name('bargain_order')
  1519. ->field('id,remark,status')
  1520. ->where(['infoNo' => $infoNo, 'bidsNo' => $value['bidNo']])
  1521. ->whereIn('status', [5, 6])
  1522. ->find();
  1523. }
  1524. $data[] = $value;
  1525. }
  1526. return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
  1527. }
  1528. public function feedlist(){
  1529. $where=[['is_del',"=",0]];
  1530. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1531. if ($zxNo !== "") {
  1532. $where[] = ['zxNo','=',$zxNo];
  1533. }
  1534. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  1535. if ($infoNo !== "") {
  1536. $where[] = ['infoNo','=',$infoNo];
  1537. }
  1538. $bidNo = isset($this->post['bidNo']) && $this->post['bidNo'] !== "" ? trim($this->post['bidNo']) : "";
  1539. if ($bidNo !== "") {
  1540. $where[] = ['bidNo','=',$bidNo];
  1541. }
  1542. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  1543. if ($projectNo !== "") {
  1544. $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column
  1545. ("zxNo");
  1546. $where[] = ['zxNo','in',$zxlist];
  1547. }
  1548. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1549. if($token==''){
  1550. return error_show(102,"参数token不能为空");
  1551. }
  1552. $is_own = isset($this->post['is_own']) ? intval($this->post['is_own']) : "0";
  1553. if($is_own==1){
  1554. $token = isset($this->post['token']) ? trim($this->post['token']) : "";
  1555. if($token==""){
  1556. return error_show(101,'token不能为空');
  1557. }
  1558. $apply_id =GetUserInfo($token);
  1559. if(empty($apply_id)||$apply_id['code']!=0){
  1560. return error_show(1002,"申请人数据不存在");
  1561. }
  1562. $rm= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
  1563. $where[]=['createrid',"=",$rm];
  1564. }
  1565. $list =Db::name('consult_bids')->where($where)->select();
  1566. $data=[];
  1567. foreach ($list as $value){
  1568. $catinfo = Db::name("cat")->where(["id"=>$value['cat_id']])->find();
  1569. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  1570. $unit =Db::name("unit")->where(["id"=>$value['unit_id']])->find();
  1571. $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1572. $supplier = Db::name("supplier")->where(["code"=>$value['supplierNo']])->find();
  1573. $value['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  1574. if($value['brand_id']!=0){
  1575. $brand=Db::name("brand")->where(["id"=>$value['brand_id']])->find();
  1576. $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1577. }else{
  1578. $value["brand_name"]="";
  1579. $value["brand_id"]="";
  1580. }
  1581. $bidinfo = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
  1582. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
  1583. $god=[
  1584. "metal_id"=>$value['metal_id'],
  1585. "weight"=>$value["weight"],
  1586. "demo_fee"=>$value["demo_fee"],
  1587. "delivery_fee"=>$value["delivery_fee"],
  1588. "open_fee"=>$value["open_fee"],
  1589. "packing_fee"=>$value["pakge_fee"],
  1590. "mark_fee"=>$value["mark_fee"],
  1591. "nake_fee"=>$value["nake_fee"],
  1592. "cert_fee"=>$value["cert_fee"],
  1593. "cost_fee"=>$value["cost_fee"],
  1594. "num"=>$bidinfo["num"],
  1595. ];
  1596. if($value['is_gold_price']==1){
  1597. $price = GoldPrice($god, $budget/100);
  1598. $value['sale_price'] =round($price,2);
  1599. }
  1600. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  1601. $value['specinfo'] = json_decode($value['specinfo'],true);
  1602. $value['bargain_status']=$bidinfo['bargain_status'];
  1603. $data[]=$value;
  1604. }
  1605. return app_show(0,"获取成功",$data);
  1606. }
  1607. public function bragain_list(){
  1608. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  1609. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  1610. $where=[['is_del',"=",0]];
  1611. $bidsNo = isset($this->post['bidsNo'])&&$this->post['bidsNo']!=""?trim($this->post['bidsNo']):"";
  1612. if($bidsNo!=""){
  1613. $where[]=["bidsNo","=",$bidsNo];
  1614. }
  1615. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1616. if ($zxNo !== "") {
  1617. $where[] = ['zxNo','=',$zxNo];
  1618. }
  1619. $infoNo = isset($this->post['infoNo']) && $this->post['infoNo'] !== "" ? trim($this->post['infoNo']) : "";
  1620. if ($infoNo !== "") {
  1621. $where[] = ['infoNo','=',$infoNo];
  1622. }
  1623. $projectNo = isset($this->post['projectNo']) && $this->post['projectNo'] !== "" ? trim($this->post['projectNo']) : "";
  1624. if ($projectNo !== "") {
  1625. $zxlist = Db::name("consult_order")->where(["projectNo"=>$projectNo,"is_del"=>0,"is_project"=>1])->column
  1626. ("zxNo");
  1627. $where[] = ['zxNo','in',$zxlist];
  1628. }
  1629. $pgNo = isset($this->post['pgNo']) && $this->post['pgNo'] !== "" ? trim($this->post['pgNo']) : "";
  1630. if ($pgNo !== "") {
  1631. $bidinfo = Db::name("consult_info")->where([["pgNo","=",$pgNo],["is_del","=",0]])->column("infoNo");
  1632. $where[] = ['infoNo','in',$bidinfo];
  1633. }
  1634. $count=Db::name("bargain_order")->where($where)->count();
  1635. $total = ceil($count / $size);
  1636. $page = $page >= $total ? $total : $page;
  1637. $list =Db::name('bargain_order')->where($where)->page($page,$size)->order('addtime','desc')->select();
  1638. $data=[];
  1639. foreach ($list as $value){
  1640. $bidinfos = Db::name("consult_bids")->where([["bidNo","=",$value['bidsNo']],["is_del","=",0]])->find();
  1641. $value['spuCode'] = isset($bidinfos['spuCode'])?$bidinfos['spuCode']:"";
  1642. $value['good_name'] = isset($bidinfos['good_name'])?$bidinfos['good_name']:"";
  1643. $value['good_img'] = isset($bidinfos['good_img'])?$bidinfos['good_img']:"";
  1644. $value['brand_id'] = isset($bidinfos['brand_id'])?$bidinfos['brand_id']:"";
  1645. if($bidinfos['brand_id']!=0){
  1646. $value['brand_id'] = $bidinfos['brand_id'];
  1647. $brand=Db::name("brand")->where(["id"=>$bidinfos['brand_id']])->find();
  1648. $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  1649. }else{
  1650. $value["brand_name"]="";
  1651. $value["brand_id"]="";
  1652. }
  1653. $catinfo = Db::name("cat")->where(["id"=>$bidinfos['cat_id']])->find();
  1654. $value['can']= isset($bidinfos['cat_id']) && $bidinfos['cat_id'] !=0 ? made($bidinfos['cat_id']):[];
  1655. $unit =Db::name("unit")->where(["id"=>$bidinfos['unit_id']])->find();
  1656. $value['unit'] = isset($unit['unit'])?$unit['unit']:'';
  1657. $bidinfoe = Db::name("consult_info")->where(["infoNo"=>$value["infoNo"]])->find();
  1658. $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']:0;
  1659. $value['budget'] =$budget;
  1660. $god=[
  1661. "metal_id"=>$bidinfos['metal_id'],
  1662. "weight"=>$bidinfos["weight"],
  1663. "demo_fee"=>$bidinfos["demo_fee"],
  1664. "delivery_fee"=>$bidinfos["delivery_fee"],
  1665. "open_fee"=>$bidinfos["open_fee"],
  1666. "packing_fee"=>$bidinfos["pakge_fee"],
  1667. "mark_fee"=>$bidinfos["mark_fee"],
  1668. "nake_fee"=>$bidinfos["nake_fee"],
  1669. "cert_fee"=>$bidinfos["cert_fee"],
  1670. "cost_fee"=>$bidinfos["cost_fee"],
  1671. "num"=>$bidinfoe["num"],
  1672. ];
  1673. // if($bidinfos['is_gold_price']==1){
  1674. // $price = GoldPrice($god, $budget/100);
  1675. // }else{
  1676. // $price = GoodPrice($god, $budget/100);
  1677. // }
  1678. $value['metal_name']=isset($bidinfos['metal_id'])&& $bidinfos['metal_id']!=0?$this->noble[$bidinfos['metal_id']]:"";
  1679. $value['sale_price'] =round($bidinfos['sale_price'],2);
  1680. $value['specinfo'] = isset($bidinfos['specinfo'])&&$bidinfos['specinfo']!=""?json_decode($bidinfos['specinfo'],true):[];
  1681. $data[]=$value;
  1682. }
  1683. return app_show(0,"获取成功",["list"=>$data,"count"=>$count]);
  1684. }
  1685. public function crontablist(){
  1686. $page = isset($this->post['page']) && $this->post['page'] !== "" ? intval($this->post['page']) :"1";
  1687. $size = isset($this->post['size']) && $this->post['size'] !== "" ? intval($this->post['size']) :"10";
  1688. $where=[['a.is_del',"=",0],['b.is_del',"=",0]];
  1689. $zxNo = isset($this->post['zxNo']) && $this->post['zxNo'] !== "" ? trim($this->post['zxNo']) : "";
  1690. if ($zxNo !== "") {
  1691. $where[] = ['a.zxNo','=',$zxNo];
  1692. }
  1693. $salesman = isset($this->post['salesman']) && $this->post['salesman'] !== "" ? trim($this->post['salesman']) : "";
  1694. if ($salesman !== "") {
  1695. //$where["salesman"] =Db::Raw("like '%$salesman%'");
  1696. $where[]= ["b.salesman",'like',"%$salesman%"];
  1697. }
  1698. $cpName = isset($this->post['cpName']) && $this->post['cpName'] !== "" ? trim($this->post['cpName']) : "";
  1699. if ($cpName !== "") {
  1700. //$where["cpName"]= Db::Raw("like '%$cpName%'");
  1701. $where[]= ["a.good_Name",'like',"%$cpName%"];
  1702. }
  1703. $khNo = isset($this->post['khNo']) && $this->post['khNo'] !== "" ? trim($this->post['khNo']) : "";
  1704. if ($khNo !== "") {
  1705. // $where['khNo'] = $khNo;
  1706. $where[]= ["b.khNo",'like',"%$khNo%"];
  1707. }
  1708. $start= isset($this->post['start']) && $this->post['start'] !== "" ? $this->post['start']:"";
  1709. if ($start !="") {
  1710. //$where = ["zxtime"=>Db::raw(">= '{$start}'")];
  1711. $where[]= ["a.addtime",'>=',$start];
  1712. }
  1713. $end = isset($this->post['end']) && $this->post['end'] !== "" ? $this->post['end'] :"";
  1714. if($end !=""){
  1715. $where[]= ["a.addtime",'<=',$end];
  1716. }
  1717. $status = isset($this->post['status']) && $this->post['status'] !== "" ? trim($this->post['status']) : "";
  1718. if ($status !== "") {
  1719. $where[]= ["a.status",'=',$status];
  1720. }
  1721. $count = Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)
  1722. ->count();
  1723. $total = ceil($count / $size);
  1724. $page = $page >= $total ? $total : $page;
  1725. $list =Db::name('consult_info')->alias("a")->leftJoin("consult_order b","a.zxNo=b.zxNo")->where($where)->page($page,$size)
  1726. ->field("a.*,b.createrid,b.creater,b.is_project,b.projectNo,b.khNo,b.endtime,b.platform_code,b.saleid,b.salesman,b.depart")->select();
  1727. $data=[];
  1728. foreach ($list as $value){
  1729. $value['can']= isset($value['cat_id']) && $value['cat_id'] !=0 ? made($value['cat_id']):[];
  1730. $brand = Db::name("brand")->where(['id'=>$value['brand_id']])->find();
  1731. $value['brand_name']= isset($brand['brand_name']) && $brand['brand_name']!='' ? $brand['brand_name']:"";
  1732. $value['khname']="";
  1733. $value['specinfo']=isset($value['specinfo'])&&$value['specinfo']!=""? json_decode($value['specinfo'],
  1734. true):[];
  1735. if($value['khNo']!==""){
  1736. $kh=Db::name("customer_info")->where(['companyNo'=>$value['khNo']])->find();
  1737. $value['khname']= isset($kh['companyName'])?$kh['companyName']:"";
  1738. }
  1739. $value['metal_name']=isset($value['metal_id'])&& $value['metal_id']!=0?$this->noble[$value['metal_id']]:"";
  1740. $data[]=$value;
  1741. }
  1742. return app_show(0,"获取成功",['count'=>$count,'list'=>$data]);
  1743. }
  1744. }