Goodup.php 90 KB

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