Goodup.php 90 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785
  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. $i=0;
  984. foreach ($spuCode as $value){
  985. $count = Db::name("good_nake")->where(["spuCode"=>$value,"is_del"=>0])->count();
  986. $ist =Db::name("good_platform")->where(["spuCode"=>$value,"platform_code"=>$platform,"is_del"=>0])->find();
  987. if($ist){
  988. $god=Db::name("good_basic")->where(["spuCode"=>$value,"is_del"=>0])->find();
  989. if($god){
  990. $tp=[];
  991. $tp['spuCode']=$value;
  992. $tp['good_name']=$god['good_name'];
  993. $tp['good_img']=$god['good_thumb_img'];
  994. $tp['exam_status']=$ist['exam_status'];
  995. $spec = Db::name("good_spec")->where(["spuCode"=>$value,"is_del"=>0])->select()->toArray();
  996. $speclist=[];
  997. if(!empty($spec)){
  998. foreach ($spec as $val){
  999. $temp=[];
  1000. $temp['id']=$val['id'];
  1001. $temp['spuCode']=$val['spuCode'];
  1002. $temp['spec_id']=$val['spec_id'];
  1003. $temp['spec_value_id']=$val['spec_value_id'];
  1004. $temp['is_del']=$val['is_del'];
  1005. $sp = Db::name("specs")->where(["id"=>$val['spec_id']])->find();
  1006. $temp['spec_name']=isset($sp["spec_name"]) ? $sp["spec_name"]:"";
  1007. $spv = Db::name("spec_value")->where(["id"=>$val['spec_value_id']])->find();
  1008. $temp['spec_value']=isset($spv["spec_value"]) ? $spv["spec_value"]:"";
  1009. $speclist[]=$temp;
  1010. }
  1011. }
  1012. $tp["speclist"]=empty($speclist)?[]:$speclist;
  1013. $isonline[]=$tp;
  1014. }
  1015. }
  1016. //改变编码规则,将原来的skuCode后两位换成序列号
  1017. //str_pad字符串填充
  1018. $skuCode = makeNo("SN");
  1019. $skuCode = substr($skuCode, 0, -2) . str_pad($i, 2, '0', STR_PAD_LEFT);
  1020. $data[]=[
  1021. "spuCode"=>$value,
  1022. "skuCode"=>$skuCode,
  1023. "platform_code"=>$platform,
  1024. "online_reason"=>$online_reason,
  1025. "online_remark"=>$online_remark,
  1026. "exam_status"=>$count>0 ?2:1,
  1027. "is_online"=>0,
  1028. "status"=>1,
  1029. "is_del"=>0,
  1030. "creater"=>$creater,
  1031. "createrid"=>$createrid,
  1032. "addtime"=>date("Y-m-d H:i:s"),
  1033. "updatetime"=>date("Y-m-d H:i:s")
  1034. ];
  1035. $i++;
  1036. }
  1037. if(!empty($isonline)){
  1038. return app_show(1009,"存在已上线产品",$isonline);
  1039. }
  1040. Db::startTrans();
  1041. $create =Db::name("good_platform")->insertAll($data);
  1042. if($create){
  1043. foreach ($datas as $value){
  1044. $iso = Db::name("good")->where(["spuCode"=>$value['spuCode'],"is_del"=>0])->find();
  1045. if($iso==false){
  1046. unset($value['id']);
  1047. $value['creater']=$creater;
  1048. $value['createrid']=$createrid;
  1049. $value['addtime']=date("Y-m-d H:i:s");
  1050. $value['updatetime']=date("Y-m-d H:i:s");
  1051. }else{
  1052. $value['id']=$iso['id'];
  1053. $value['creater']=$creater;
  1054. $value['createrid']=$createrid;
  1055. $value['updatetime']=date("Y-m-d H:i:s");
  1056. }
  1057. $up =Db::name("good")->save($value);
  1058. if(!$up){
  1059. Db::rollback();
  1060. return error_show(1004,"提交失败");
  1061. }
  1062. }
  1063. Db::commit();
  1064. return app_show(0,"提交成功");
  1065. }else{
  1066. Db::rollback();
  1067. return error_show(1004,"提交失败");
  1068. }
  1069. }
  1070. public function online_exam(){
  1071. $skuCode = isset($this->post['skuCode'])&&$this->post['skuCode']!==""?trim($this->post['skuCode']):"";
  1072. if($skuCode===""){
  1073. return error_show(1004,"参数skuCode不能为空");
  1074. }
  1075. $platform = Db::name("good_platform")->where(["skuCode"=>$skuCode,"is_del"=>0])->find();
  1076. if($platform==false){
  1077. return error_show(1004,"未找到数据");
  1078. }
  1079. $exam_status=isset($this->post['exam_status'])&&$this->post['exam_status']!==""?intval($this->post['exam_status']):"";
  1080. // if($exam_status===""){
  1081. // return error_show(1004,"参数exam_status不能为空");
  1082. // }
  1083. if($exam_status==3){
  1084. $online_time= isset($this->post['online_time'])&&$this->post['online_time']!==""?$this->post['online_time']:"";
  1085. if($online_time===""){
  1086. return error_show(1004,"参数online_time不能为空");
  1087. }
  1088. $platform['online_time']=$online_time;
  1089. }
  1090. if($exam_status==6){
  1091. $good_code= isset($this->post['plat_code'])&&$this->post['plat_code']!==""?trim($this->post['plat_code']):"";
  1092. if($good_code===""){
  1093. return error_show(1004,"参数plat_code不能为空");
  1094. }
  1095. $platform['plat_code']=$good_code;
  1096. }
  1097. $exam_remark = isset($this->post['exam_remark'])&&$this->post['exam_remark']!==""?trim($this->post['exam_remark']):"";
  1098. $platform['exam_status']=$exam_status;
  1099. $platform['updatetime']=date("Y-m-d H:i:s");
  1100. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1101. if($token==''){
  1102. return error_show(105,"参数token不能为空");
  1103. }
  1104. $user =GetUserInfo($token);
  1105. if(empty($user)||$user['code']!=0){
  1106. return error_show(1002,"用户数据不存在");
  1107. }
  1108. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1109. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1110. Db::startTrans();
  1111. try {
  1112. $up = Db::name("good_platform")->save($platform);
  1113. if($up){
  1114. $data=[
  1115. "code"=>$platform['skuCode'],
  1116. "exam_status"=>$exam_status,
  1117. "type"=>2,
  1118. "exam_id"=>$createrid,
  1119. "exam_name"=>$creater,
  1120. "exam_remark"=>$exam_remark,
  1121. "addtime"=>date("Y-m-d H:i:s")
  1122. ];
  1123. $inr=Db::name("good_exam")->insert($data);
  1124. if($inr){
  1125. Db::commit();
  1126. return app_show(0,"审核成功");
  1127. }else{
  1128. Db::rollback();
  1129. return error_show(1004,"审核失败");
  1130. }
  1131. }else{
  1132. Db::rollback();
  1133. return error_show(1004,"审核失败");
  1134. }
  1135. }catch (\Exception $e){
  1136. Db::rollback();
  1137. return error_show(1004,$e->getMessage());
  1138. }
  1139. }
  1140. public function editladder(){
  1141. $skuCode = isset($this->post['skuCode'])&&$this->post['skuCode']!==""?trim($this->post['skuCode']):"";
  1142. if($skuCode===""){
  1143. return error_show(1004,"参数skuCode不能为空");
  1144. }
  1145. $platform = Db::name("good_platform")->where(["skuCode"=>$skuCode,"is_del"=>0])->find();
  1146. if($platform==false){
  1147. return error_show(1004,"未找到数据");
  1148. }
  1149. $good_ladder = isset($this->post['good_ladder'])&&!empty($this->post['good_ladder'])?$this->post['good_ladder']:"";
  1150. if($good_ladder==""){
  1151. return error_show(1004,"参数good_ladder不能为空");
  1152. }
  1153. $proof_type = isset($this->post['proof_type'])&&$this->post['proof_type']!==""?intval($this->post['proof_type']):"";
  1154. if($proof_type===""){
  1155. return error_show(1004,"参数proof_type不能为空");
  1156. }
  1157. $proof_url = isset($this->post['proof_url'])&&$this->post['proof_url']!==""?trim($this->post['proof_url']):"";
  1158. if($proof_url===""){
  1159. return error_show(1004,"参数proof_url不能为空");
  1160. }
  1161. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1162. if($token==''){
  1163. return error_show(105,"参数token不能为空");
  1164. }
  1165. $user =GetUserInfo($token);
  1166. if(empty($user)||$user['code']!=0){
  1167. return error_show(1002,"用户数据不存在");
  1168. }
  1169. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1170. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1171. $platform['exam_status']=4;
  1172. $platform['updatetime']=date("Y-m-d H:i:s");
  1173. Db::startTrans();
  1174. try {
  1175. foreach ($good_ladder as $value){
  1176. $lemp=[];
  1177. isset($value["id"])&&$value["id"]!=""?$lemp['id']=$value['id']:"";
  1178. $lemp['skuCode']=$skuCode;
  1179. $lemp['min_num'] = $value['min_num'];
  1180. $lemp['max_num'] = 0;
  1181. $lemp['sale_price'] = $value['sale_price'];
  1182. $lemp['market_price'] = $value['market_price'];
  1183. $lemp['market_platform'] = $value['market_platform'];
  1184. $lemp['status'] = $value['status'];
  1185. $lemp['is_del'] = isset($value['is_del'])?$value['is_del']:0;
  1186. isset($value["id"])&&$value["id"]!=""?"": $lemp['addtime'] = date("Y-m-d H:i:s");
  1187. $lemp['updatetime'] =date("Y-m-d H:i:s");
  1188. $count = Db::name("good_ladder")->save($lemp);
  1189. if($count==false){
  1190. Db::rollback();
  1191. return app_show(1004,"商品起订价修改失败");
  1192. }
  1193. }
  1194. $up = Db::name("good_platform")->save($platform);
  1195. if($up){
  1196. $proof=[
  1197. 'spuCode'=>$platform['spuCode'],
  1198. 'proof_type'=>$proof_type,
  1199. 'proof_url'=>$proof_url,
  1200. 'is_del'=>0,
  1201. "creater"=>$creater,
  1202. "createrid"=>$createrid,
  1203. "addtime"=>date("Y-m-d H:i:s"),
  1204. "updatetime"=>date("Y-m-d H:i:s")
  1205. ];
  1206. $inproof = Db::name("good_proof")->insert($proof);
  1207. if($inproof==false){
  1208. Db::rollback();
  1209. return app_show(1004,"商品凭证新建失败");
  1210. }
  1211. $data=[
  1212. "code"=>$platform['skuCode'],
  1213. "type"=>2,
  1214. "exam_status"=>4,
  1215. "exam_id"=>$createrid,
  1216. "exam_name"=>$creater,
  1217. "exam_remark"=>'',
  1218. "addtime"=>date("Y-m-d H:i:s")
  1219. ];
  1220. $inr=Db::name("good_exam")->insert($data);
  1221. if($inr){
  1222. Db::commit();
  1223. return app_show(0,"审核成功");
  1224. }else{
  1225. Db::rollback();
  1226. return error_show(1004,"审核失败");
  1227. }
  1228. }else{
  1229. Db::rollback();
  1230. return error_show(1004,"审核失败");
  1231. }
  1232. }catch (\Exception $e){
  1233. Db::rollback();
  1234. return error_show(1004,$e->getMessage());
  1235. }
  1236. }
  1237. public function prooflist(){
  1238. $page = isset($this->post['page']) && $this->post['page'] !==""? intval($this->post['page']):"1";
  1239. $size = isset($this->post['size']) && $this->post['size'] !==""? intval($this->post['size']):"10";
  1240. $where =[["is_del","=",0]];
  1241. $spuCode = isset($this->post['spuCode'])&&$this->post['spuCode']!="" ? trim($this->post['spuCode']):"";
  1242. if($spuCode!==""){
  1243. $where[]=["spuCode","like","%$spuCode%"];
  1244. }
  1245. $count = Db::name("good_proof")->where($where)->count();
  1246. $total = ceil($count / $size);
  1247. $page = $page >= $total ? $total : $page;
  1248. $data = Db::name("good_proof")->where($where)->page($page,$size)->order("addtime desc")->select();
  1249. return app_show(0,"获取成功",['list'=>$data,"count"=>$count]);
  1250. }
  1251. /**
  1252. *
  1253. */
  1254. public function againOnline(){
  1255. $skuCode = isset($this->post['skuCode'])&&$this->post['skuCode']!==""?trim($this->post['skuCode']):"";
  1256. if($skuCode===""){
  1257. return error_show(1004,"参数skuCode不能为空");
  1258. }
  1259. $platform = Db::name("good_platform")->where(["skuCode"=>$skuCode,"is_del"=>0])->find();
  1260. if($platform==false){
  1261. return error_show(1004,"未找到数据");
  1262. }
  1263. if($platform["exam_status"]!=7&&$platform["exam_status"]!=8){
  1264. return error_show(1004,"商品状态有误");
  1265. }
  1266. $nake =Db::name("good_nake")->where(["spuCode"=>$platform['spuCode'],"is_del"=>0])->select()->toArray();
  1267. $platform['exam_status'] = empty($nake)?1:2;
  1268. $platform['updatetime'] = date("Y-m-d H:i:s");
  1269. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1270. if($token==''){
  1271. return error_show(105,"参数token不能为空");
  1272. }
  1273. $user =GetUserInfo($token);
  1274. if(empty($user)||$user['code']!=0){
  1275. return error_show(1002,"用户数据不存在");
  1276. }
  1277. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1278. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1279. Db::startTrans();
  1280. try {
  1281. $save =Db::name("good_platform")->save($platform);
  1282. if($save){
  1283. $data=[
  1284. "code"=>$platform['skuCode'],
  1285. "type"=>2,
  1286. "exam_status"=>$platform['exam_status'] ,
  1287. "exam_id"=>$createrid,
  1288. "exam_name"=>$creater,
  1289. "exam_remark"=>'',
  1290. "addtime"=>date("Y-m-d H:i:s")
  1291. ];
  1292. $inr=Db::name("good_exam")->insert($data);
  1293. if($inr){
  1294. Db::commit();
  1295. return app_show(0,"审核成功");
  1296. }
  1297. }
  1298. Db::rollback();
  1299. return error_show(1004,"审核失败");
  1300. }catch (\Exception $e){
  1301. Db::rollback();
  1302. return error_show(1004,$e->getMessage());
  1303. }
  1304. }
  1305. public function copy(){
  1306. $supcode = isset($this->post['spuCode'])&&$this->post['spuCode']!="" ? trim($this->post['spuCode']):"";
  1307. if($supcode==""){
  1308. return error_show(1004,"参数spuCode不能为空");
  1309. }
  1310. $data = Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->find();
  1311. if($data==false){
  1312. return error_show(1004,"未找到商品数据");
  1313. }
  1314. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1315. if($token==''){
  1316. return error_show(105,"参数token不能为空");
  1317. }
  1318. $user =GetUserInfo($token);
  1319. if(empty($user)||$user['code']!=0){
  1320. return error_show(102,"用户数据不存在");
  1321. }
  1322. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1323. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1324. $nake = Db::name("good_nake")->where(["spuCode"=>$supcode,"is_del"=>0])->select()->toArray();
  1325. $ladd=[];
  1326. $newCode =makeNo("SKU");
  1327. if(!empty($nake)){
  1328. foreach ($nake as $value){
  1329. $tmp=[];
  1330. $tmp['spuCode']=$newCode;
  1331. $tmp['min_num']=$value['min_num'];
  1332. $tmp['nake_fee'] = $value['nake_fee'];
  1333. $tmp['cost_fee'] = $value['cost_fee'];
  1334. $tmp['delivery_fee'] = $value['delivery_fee'];
  1335. $tmp['cert_fee'] = $value['cert_fee'];
  1336. $tmp['mark_fee'] = $value['mark_fee'];
  1337. $tmp['package_fee'] = $value['package_fee'];
  1338. $tmp['other_fee'] = $value['other_fee'];
  1339. $tmp['nake_total'] =$value['nake_total'];
  1340. $tmp['creater_id']=$createrid;
  1341. $tmp['creater']=$creater;
  1342. $tmp['is_del']=$value['is_del'];
  1343. $tmp['addtime']=date("Y-m-d H:i:s");
  1344. $tmp['updatetime']=date("Y-m-d H:i:s");
  1345. $ladd[]=$tmp;
  1346. }
  1347. }
  1348. $spec = Db::name("good_spec")->where(["spuCode"=>$supcode,"is_del"=>0])->select()->toArray();
  1349. $specArr=[];
  1350. if(!empty($spec)){
  1351. foreach ($spec as $value){
  1352. $tmp=[];
  1353. $tmp['spuCode']=$newCode;
  1354. $tmp['spec_id']=$value['spec_id'];
  1355. $tmp['spec_value_id']=$value['spec_value_id'];
  1356. $tmp['is_del']=$value['is_del'];
  1357. $tmp['addtime']=date("Y-m-d H:i:s");
  1358. $tmp['updatetime']=date("Y-m-d H:i:s");
  1359. $specArr[]=$tmp;
  1360. }
  1361. }
  1362. Db::startTrans();
  1363. try {
  1364. unset($data['id']);
  1365. $data['spuCode']=$newCode;
  1366. $data['createrid']=$createrid;
  1367. $data['creater']=$creater;
  1368. $data['status']=7;
  1369. $data['addtime']=date("Y-m-d H:i:s");
  1370. $data['updatetime']=date("Y-m-d H:i:s");
  1371. $cre = Db::name("good_basic")->insert($data);
  1372. if($cre){
  1373. if(!empty($ladd)){
  1374. $na = Db::name("good_nake")->insertAll($ladd);
  1375. if($na==0){
  1376. Db::rollback();
  1377. return error_show(1005,"成本数据复制失败");
  1378. }
  1379. }
  1380. if(!empty($specArr)){
  1381. $sp = Db::name("good_spec")->insertAll($specArr);
  1382. if($sp==0){
  1383. Db::rollback();
  1384. return error_show(1005,"规格数据复制失败");
  1385. }
  1386. }
  1387. Db::commit();
  1388. return app_show(0,"复制数据成功",["spuCode"=>$newCode]);
  1389. }else{
  1390. Db::rollback();
  1391. return error_show(1005,"数据复制失败");
  1392. }
  1393. }catch (\Exception $e){
  1394. Db::rollback();
  1395. return error_show(1004,$e->getMessage());
  1396. }
  1397. }
  1398. public function edit(){
  1399. $supcode = isset($this->post['spuCode'])&&$this->post['spuCode']!="" ? trim($this->post['spuCode']):"";
  1400. if($supcode==""){
  1401. return error_show(1004,"参数spuCode不能为空");
  1402. }
  1403. $data = Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->find();
  1404. if($data==false){
  1405. return error_show(1004,"未找到商品数据");
  1406. }
  1407. if($data['status']!=6 &&$data['status']!=7 ){
  1408. return error_show(1004,"商品状态有误");
  1409. }
  1410. $good_name= isset($this->post['good_name'])&&$this->post['good_name']!="" ? trim($this->post['good_name']):"";
  1411. if($good_name==""){
  1412. return error_show(1004,"商品名称不能为空");
  1413. }
  1414. $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? intval($this->post['cat_id']):"";
  1415. if($cat_id==''){
  1416. return error_show(1004,"商品分类不能为空");
  1417. }
  1418. $brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):"0";
  1419. // if($brandid==''){
  1420. // return error_show(1004,"商品品牌不能为空");
  1421. // }
  1422. $unit = isset($this->post['unit'])&&$this->post['unit']!=""? trim($this->post['unit']):"";
  1423. if($unit==''){
  1424. return error_show(1004,"商品单位不能为空");
  1425. }
  1426. $good_type = isset($this->post['good_type'])&&$this->post['good_type']!==""? intval($this->post['good_type'])
  1427. :"";
  1428. if($good_type===''){
  1429. return error_show(1004,"参数good_type不能为空");
  1430. }
  1431. $moq=0;
  1432. $customized=0;
  1433. if($good_type==1){
  1434. $moq = isset($this->post['moq'])&&$this->post['moq']!==""? intval($this->post['moq']):"";
  1435. if($moq===''){
  1436. return error_show(1004,"定制商品起订量不能为空");
  1437. }
  1438. $customized = isset($this->post['customized'])&&$this->post['customized']!==""? intval($this->post['customized']):"";
  1439. if($customized===''){
  1440. return error_show(1004,"参数customized不能为空");
  1441. }
  1442. }
  1443. $is_exclusive = isset($this->post['is_exclusive'])&&$this->post['is_exclusive']!==""? intval($this->post['is_exclusive']):"";
  1444. if($is_exclusive===''){
  1445. return error_show(1004,"参数is_exclusive不能为空");
  1446. }
  1447. // $customized = isset($this->post['customized'])&&$this->post['customized']!==""? intval($this->post['customized']):"";
  1448. // if($customized===''){
  1449. // return error_show(1004,"参数customized不能为空");
  1450. // }
  1451. $tax = isset($this->post['tax'])&&$this->post['tax']!==""? intval($this->post['tax']):"";
  1452. if($tax===''){
  1453. return error_show(1004,"参数tax不能为空");
  1454. }
  1455. $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
  1456. if($supplierNo==''){
  1457. return error_show(1004,"参数supplierNo不能为空");
  1458. }
  1459. $good_size = isset($this->post['good_size'])&&$this->post['good_size']!=""? trim($this->post['good_size'])
  1460. :"";
  1461. if($good_size==''){
  1462. return error_show(1004,"参数good_size不能为空");
  1463. }
  1464. $company_id = isset($this->post['companyNo'])&&$this->post['companyNo']!=""? trim($this->post['companyNo'])
  1465. :"";
  1466. if($company_id==''){
  1467. return error_show(1004,"参数companyNo不能为空");
  1468. }
  1469. $is_auth = isset($this->post['is_auth'])&&$this->post['is_auth']!==""? intval($this->post['is_auth']):"";
  1470. if($is_auth===''){
  1471. return error_show(1004,"参数is_auth不能为空");
  1472. }
  1473. $auth_img = isset($this->post['auth_img'])&&$this->post['auth_img']!=""? trim($this->post['auth_img']):"";
  1474. // if($auth_img==''){
  1475. // return error_show(1004,"商品不能为空");
  1476. // }
  1477. $after_sales = isset($this->post['after_sales'])&&$this->post['after_sales']!=""? trim($this->post['after_sales']):"";
  1478. if($after_sales==""){
  1479. return error_show(1004,"参数after_sales不能为空");
  1480. }
  1481. $craft_desc = isset($this->post['craft_desc'])&&$this->post['craft_desc']!=""? trim($this->post['craft_desc']):"";
  1482. $good_remark = isset($this->post['good_remark'])&&$this->post['good_remark']!=""? trim($this->post['good_remark']):"";
  1483. if($good_remark===""){
  1484. return error_show(1004,"参数good_remark不能为空");
  1485. }
  1486. $weight = isset($this->post['weight'])&&$this->post['weight']!==""? floatval($this->post['weight']):"";
  1487. if($weight===""){
  1488. return error_show(1004,"参数weight不能为空");
  1489. }
  1490. $packing_way = isset($this->post['packing_way'])&&$this->post['packing_way']!==""? trim($this->post['packing_way']):"";
  1491. if($packing_way===""){
  1492. return error_show(1004,"参数packing_way不能为空");
  1493. }
  1494. $packing_size = isset($this->post['packing_size'])&&$this->post['packing_size']!==""? trim($this->post['packing_size']):"";
  1495. if($packing_size===""){
  1496. return error_show(1004,"参数packing_size不能为空");
  1497. }
  1498. $packing_spec = isset($this->post['packing_spec'])&&$this->post['packing_spec']!==""? trim($this->post['packing_spec']):"";
  1499. if($packing_spec===""){
  1500. return error_show(1004,"参数packing_spec不能为空");
  1501. }
  1502. $packing_weight = isset($this->post['packing_weight'])&&$this->post['packing_weight']!==""? floatval($this->post['packing_weight']):"";
  1503. if($packing_weight===""){
  1504. return error_show(1004,"参数packing_weight不能为空");
  1505. }
  1506. $packing_list = isset($this->post['packing_list'])&&$this->post['packing_list']!==""? trim($this->post['packing_list']):"";
  1507. if($packing_list===""){
  1508. return error_show(1004,"参数packing_list不能为空");
  1509. }
  1510. $good_bar = isset($this->post['good_bar'])&&$this->post['good_bar']!==""? trim($this->post['good_bar']):"";
  1511. $supply_area = isset($this->post['supply_area'])&&$this->post['supply_area']!==""? intval($this->post['supply_area']):"";
  1512. if($supply_area===""){
  1513. return error_show(1004,"参数supply_area不能为空");
  1514. }
  1515. $delivery_place = isset($this->post['delivery_place'])&&$this->post['delivery_place']!==""? $this->post['delivery_place']:"";
  1516. if($delivery_place===""){
  1517. return error_show(1004,"参数delivery_place不能为空");
  1518. }
  1519. $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!==""? $this->post['origin_place']:"";
  1520. if($origin_place===""){
  1521. return error_show(1004,"参数origin_place不能为空");
  1522. }
  1523. $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!==""? intval($this->post['delivery_day']):"";
  1524. if($delivery_day===""){
  1525. return error_show(1004,"参数delivery_day不能为空");
  1526. }
  1527. $lead_time = isset($this->post['lead_time'])&&$this->post['lead_time']!==""? intval($this->post['lead_time'])
  1528. :"0";
  1529. // if($lead_time===""){
  1530. // return error_show(1004,"参数lead_time不能为空");
  1531. // }
  1532. $sample_day = isset($this->post['sample_day'])&&$this->post['sample_day']!==""? intval($this->post['sample_day']):"0";
  1533. // if($sample_day===""){
  1534. // return error_show(1004,"参数sample_day不能为空");
  1535. // }
  1536. $sample_fee = isset($this->post['sample_fee'])&&$this->post['sample_fee']!==""? floatval($this->post['sample_fee']):"0";
  1537. $good_img = isset($this->post['good_img'])&&$this->post['good_img']!=""? trim($this->post['good_img']):"";
  1538. if($good_img===""){
  1539. return error_show(1004,"参数good_img不能为空");
  1540. }
  1541. $good_thumb_img = isset($this->post['good_thumb_img'])&&$this->post['good_thumb_img']!==""? trim($this->post['good_thumb_img']):"";
  1542. if($good_thumb_img===""){
  1543. return error_show(1004,"参数good_thumb_img不能为空");
  1544. }
  1545. $good_info_img = isset($this->post['good_info_img'])&&!empty($this->post['good_info_img'])? trim($this->post['good_info_img']):"";
  1546. if($good_info_img===""){
  1547. return error_show(1004,"参数good_info_img不能为空");
  1548. }
  1549. $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!==""? floatval($this->post['cert_fee']):"0";
  1550. $packing_fee = isset($this->post['packing_fee'])&&$this->post['packing_fee']!==""? floatval($this->post['packing_fee']):"0";
  1551. $cost_fee = isset($this->post['cost_fee'])&&$this->post['cost_fee']!==""? floatval($this->post['cost_fee']):"0";
  1552. $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!==""? floatval($this->post['mark_fee']):"0";
  1553. $demo_fee = isset($this->post['demo_fee'])&&$this->post['demo_fee']!==""? floatval($this->post['demo_fee']):"0";
  1554. $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!==""? floatval($this->post['open_fee']):"0";
  1555. $noble_metal = isset($this->post['noble_metal'])&&$this->post['noble_metal']!==""? intval($this->post['noble_metal']):"0";
  1556. $noble_weight = isset($this->post['noble_weight'])&&$this->post['noble_weight']!==""? floatval($this->post['noble_weight']):"0";
  1557. $is_gold_price= isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!==""? intval($this->post['is_gold_price']):"0";
  1558. $market_price = isset($this->post['market_price'])&&$this->post['market_price']!==""? floatval($this->post['market_price']):"";
  1559. $cgd_gold_price = isset($this->post['cgd_gold_price'])&&$this->post['cgd_gold_price']!==""? floatval($this->post['cgd_gold_price']):"0";
  1560. if($market_price===""){
  1561. return error_show(1004,"参数market_price不能为空");
  1562. }
  1563. $nake_price = isset($this->post['nake_price'])&&$this->post['nake_price']!==""? floatval($this->post['nake_price']):"0";
  1564. $config = isset($this->post['config'])&&$this->post['config']!==""? trim($this->post['config']):"";
  1565. $other_config = isset($this->post['other_config'])&&$this->post['other_config']!==""? trim($this->post['other_config']):"";
  1566. $is_diff = isset($this->post['is_diff'])&&$this->post['is_diff']!==""? intval($this->post['is_diff']):"0";
  1567. $is_stock = isset($this->post['is_stock'])&&$this->post['is_stock']!==""? intval($this->post['is_stock']):"0";
  1568. // $is_step = isset($this->post['is_step'])&&$this->post['is_step']!==""? intval($this->post['is_step']):"";
  1569. // if($is_step===""){
  1570. // return error_show(1004,"参数is_step不能为空");
  1571. // }
  1572. $good_ladder = isset($this->post['good_ladder'])&&!empty($this->post['good_ladder'])? $this->post['good_ladder']:"";
  1573. // if($is_step==1 && $good_ladder==""){
  1574. // return error_show(1004,"启用阶梯,阶梯价不能为空");
  1575. // }
  1576. $speclist = isset($this->post['speclist'])&&!empty($this->post['speclist'])? $this->post['speclist']:"";
  1577. Db::startTrans();
  1578. try {
  1579. $temp=[
  1580. "good_name"=>$good_name,
  1581. "cat_id"=>$cat_id,
  1582. 'brand_id'=>$brandid,
  1583. "good_unit"=>$unit,
  1584. "good_type"=>$good_type,
  1585. "companyNo"=>$company_id,
  1586. "moq"=>$moq,
  1587. "is_exclusive"=>$is_exclusive,
  1588. "customized"=>$customized,
  1589. "tax"=>$tax,
  1590. "supplierNo"=>$supplierNo,
  1591. "is_auth"=>$is_auth,
  1592. "good_size"=>$good_size,
  1593. "auth_img"=>$auth_img,
  1594. "after_sales"=>$after_sales,
  1595. "craft_desc"=>$craft_desc,
  1596. "good_remark"=>$good_remark,
  1597. "weight"=>$weight,
  1598. "packing_way"=>$packing_way,
  1599. "packing_size"=>$packing_size,
  1600. "packing_spec"=>$packing_spec,
  1601. "packing_list"=>$packing_list,
  1602. "packing_weight"=>$packing_weight,
  1603. "good_bar"=>$good_bar,
  1604. "supply_area"=>$supply_area,
  1605. "delivery_place"=>$delivery_place,
  1606. "origin_place"=>$origin_place,
  1607. "delivery_day"=>$delivery_day,
  1608. "lead_time"=>$lead_time,
  1609. "sample_day"=>$sample_day,
  1610. "sample_fee"=>$sample_fee,
  1611. "good_img"=>$good_img,
  1612. "good_thumb_img"=>$good_thumb_img,
  1613. "good_info_img"=>$good_info_img,
  1614. "cert_fee"=>$cert_fee,
  1615. "packing_fee"=>$packing_fee,
  1616. "is_diff"=>$is_diff,
  1617. "config"=>$config,
  1618. "other_config"=>$other_config,
  1619. "is_stock"=>$is_stock,
  1620. "cost_fee"=>$cost_fee,
  1621. "mark_fee"=>$mark_fee,
  1622. "demo_fee"=>$demo_fee,
  1623. "open_fee"=>$open_fee,
  1624. "noble_metal"=>$noble_metal,
  1625. "noble_weight"=>$noble_weight,
  1626. "is_gold_price"=>$is_gold_price,
  1627. "market_price"=>$market_price,
  1628. "nake_price"=>$nake_price,
  1629. "cgd_gold_price"=>$cgd_gold_price,
  1630. "is_step" => count($good_ladder) > 1 ? 1 : 0,
  1631. "status"=>"0",
  1632. "updatetime"=>date("Y-m-d H:i:s")
  1633. ];
  1634. $field = array_diff_assoc($temp,$data);
  1635. $temp['field_change'] =empty($field)?"":json_encode(array_keys($field));
  1636. $up = Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->save($temp);
  1637. $var = array_diff($temp,$data);
  1638. $json = json_encode($var,JSON_UNESCAPED_UNICODE);
  1639. $dat = json_encode($data,JSON_UNESCAPED_UNICODE);
  1640. if($up){
  1641. ChangeLog::logAdd(3,$data['spuCode'],$dat,$json,$this->post['token'],$this->post);
  1642. if($speclist!=="" && !empty($speclist)){
  1643. foreach ($speclist as $value){
  1644. $lemp=[];
  1645. isset($value["id"])&&$value["id"]!=''?$lemp['id']=$value['id']:"";
  1646. $lemp['spuCode']=$supcode;
  1647. $lemp['spec_id'] = $value['spec_id'];
  1648. $lemp['spec_value_id'] = $value['spec_value_id'];
  1649. $lemp['is_del'] = isset($value['is_del'])?$value['is_del']:0;
  1650. isset($value["id"])&&$value["id"]!=''?"": $lemp['addtime'] = date("Y-m-d H:i:s");
  1651. $lemp['updatetime'] =date("Y-m-d H:i:s");
  1652. $count = Db::name("good_spec")->save($lemp);
  1653. if($count==false){
  1654. Db::rollback();
  1655. return app_show(1004,"商品规格值修改失败");
  1656. }
  1657. }
  1658. }
  1659. if($good_ladder!=="" && !empty($good_ladder)){
  1660. $user =GetUserInfo($this->post['token']);//获取用户信息,下面更新成本表的创建人
  1661. foreach ($good_ladder as $value){
  1662. $lemp=[];
  1663. isset($value["id"])&&$value["id"]!=''?$lemp['id']=$value['id']:"";
  1664. $lemp['spuCode']=$supcode;
  1665. $lemp['min_num'] = $value['min_num'];
  1666. $lemp['nake_fee'] = $value['nake_fee'];
  1667. $lemp['cost_fee'] = $value['cost_fee'];
  1668. $lemp['delivery_fee'] = $value['delivery_fee'];
  1669. $lemp['cert_fee'] = $value['cert_fee'];
  1670. $lemp['mark_fee'] = $value['mark_fee'];
  1671. $lemp['package_fee'] = $value['package_fee'];
  1672. $lemp['other_fee'] = $value['other_fee'];
  1673. if($is_gold_price==1){
  1674. $gold =Db::name("gold_price1")->where(["type"=>$noble_metal,"status"=>1,"is_del"=>0])
  1675. ->order("addtime desc")->find();
  1676. $lemp['nake_total'] =$noble_weight*$gold['price'] + $value['cost_fee']*
  1677. $noble_weight+$value['mark_fee']+$value['package_fee']+$value['cert_fee']+$value['nake_fee']+$value['delivery_fee']+$value['other_fee'];
  1678. }else{
  1679. $lemp['nake_total'] =$value['nake_fee']+$value['delivery_fee']+$value['cert_fee']+$value['mark_fee']+$value['package_fee']+$value['other_fee'];
  1680. }
  1681. $lemp['creater_id'] = isset($user["data"]['id']) ? $user["data"]['id'] : 0;
  1682. $lemp['creater'] = isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1683. $lemp['is_del'] = isset($value['is_del'])?$value['is_del']:0;
  1684. isset($value["id"])&&$value["id"]!=''?"": $lemp['addtime'] = date("Y-m-d H:i:s");
  1685. $lemp['updatetime'] =date("Y-m-d H:i:s");
  1686. $count = Db::name("good_nake")->save($lemp);
  1687. if($count==false){
  1688. Db::rollback();
  1689. return app_show(1004,"商品规成本修改失败");
  1690. }
  1691. }
  1692. }
  1693. Db::commit();
  1694. return app_show(0,"更新成功");
  1695. }else{
  1696. Db::rollback();
  1697. return error_show(1005,"更新失败");
  1698. }
  1699. }catch (\Exception $e){
  1700. Db::rollback();
  1701. return error_show(1004,$e->getMessage());
  1702. }
  1703. }
  1704. public function checkPrice(){
  1705. $spuCode=isset($this->post['spuCode'])&&$this->post['spuCode']!=""? trim($this->post['spuCode']):"";
  1706. if($spuCode==""){
  1707. return error_show(1005,"参数spuCode不能为空");
  1708. }
  1709. $good =Db::name("good_basic")->where(["spuCode"=>$spuCode,"is_del"=>0])->find();
  1710. if($good==false){
  1711. return error_show(1005,"商品数据未找到");
  1712. }
  1713. $num=isset($this->post['min_num'])&&$this->post['min_num']!=="" ? intval($this->post['min_num']):"";
  1714. if($num==""){
  1715. return error_show(1005,"参数min_num不能为空");
  1716. }
  1717. $nakelist = Db::name("good_nake")->where(['spuCode'=>$spuCode,"is_del"=>0])->where([["min_num","<=",$num]])
  1718. ->order("min_num desc")->find();
  1719. if($nakelist==false){
  1720. $nakelist = Db::name("good_nake")->where(['spuCode'=>$spuCode,"is_del"=>0])->order("min_num asc")->find();
  1721. return error_show(1010,"起订量不足{$nakelist['min_num']}");
  1722. }
  1723. $catinfo = Db::name("cat")->where(["id"=>$good['cat_id']])->find();
  1724. $budget = isset($catinfo['sale_rate']) ? $catinfo['sale_rate']/100:0;
  1725. if($good['is_gold_price']==1){
  1726. $saleprice = $good['noble_weight']*$good["cgd_gold_price"] + $nakelist['cost_fee']/(1-$budget)*
  1727. $good['noble_weight']+$nakelist['mark_fee']+$nakelist['package_fee']+$nakelist['cert_fee']+$nakelist['nake_fee']+$nakelist['delivery_fee'];
  1728. }else{
  1729. $saleprice =$nakelist['mark_fee']+$nakelist['package_fee']+$nakelist['cert_fee']+$nakelist['delivery_fee']+$nakelist['nake_fee']/(1-$budget);
  1730. }
  1731. return app_show(0,"获取成功",["sale_price"=>round($saleprice,2)]);
  1732. }
  1733. }