Goodup.php 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033
  1. <?php
  2. namespace app\admin\controller;
  3. use app\BaseController;
  4. use think\App;
  5. use think\facade\Db;
  6. class Goodup extends BaseController
  7. {
  8. public $post="";
  9. public function __construct(App $app)
  10. {
  11. parent::__construct($app);
  12. $this->post=$this->request->post();
  13. }
  14. public function list(){
  15. $page = isset($this->post['page']) && $this->post['page'] !==""? intval($this->post['page']):"1";
  16. $size = isset($this->post['size']) && $this->post['size'] !==""? intval($this->post['size']):"10";
  17. $where =[["is_del","=",0]];
  18. $cat_id = isset($this->post['cat_id']) && $this->post['cat_id'] !=="" ? intval($this->post['cat_id']):"";
  19. if($cat_id!==""){
  20. $where[]=['cat_id',"=",$cat_id];
  21. }
  22. $good_name = isset($this->post['good_name']) && $this->post['good_name'] !=="" ? trim($this->post['good_name']):"";
  23. if($good_name!==""){
  24. $where[]=['good_name',"like","%$good_name%"];
  25. }
  26. $spucode = isset($this->post['spucode']) && $this->post['spucode'] !=="" ? trim($this->post['spucode'])
  27. :"";
  28. if($spucode!==""){
  29. $where[]=['spuCode',"like","%$spucode%"];
  30. }
  31. $good_type = isset($this->post['good_type']) && $this->post['good_type'] !=="" ? trim($this->post['good_type'])
  32. :"";
  33. if($good_type!==""){
  34. $where[]=['good_type',"=",$good_type];
  35. }
  36. $companyNo = isset($this->post['companyNo']) && $this->post['companyNo'] !=="" ? trim($this->post['companyNo'])
  37. :"";
  38. if($companyNo!==""){
  39. $where[]=['companyNo',"like","%$companyNo%"];
  40. }
  41. $supplierNo = isset($this->post['supplierNo']) && $this->post['supplierNo'] !=="" ? trim($this->post['supplierNo'])
  42. :"";
  43. if($supplierNo!==""){
  44. $where[]=['supplierNo',"like","%$supplierNo%"];
  45. }
  46. $brandid = isset($this->post['brandid']) && $this->post['brandid'] !=="" ? intval($this->post['brandid'])
  47. :"";
  48. if($brandid!==""){
  49. $where[]=['brand_id',"=",$brandid];
  50. }
  51. $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status'])
  52. :"";
  53. if($status!==""){
  54. $where[]=['status',"=",$status];
  55. }
  56. $start = isset($this->post['start']) && $this->post['start']!=="" ? $this->post['start']:"";
  57. if($start!==""){
  58. $where[]=['addtime',">=",date('Y-m-d H:i:s',strtotime($start))];
  59. }
  60. $end = isset($this->post['end']) && $this->post['end']!=="" ? $this->post['end']:"";
  61. if($end!==""){
  62. $where[]=['addtime',"<",date('Y-m-d H:i:s',strtotime($end)+24*3600)];
  63. }
  64. $count = Db::name('good_basic')->where($where)->count();
  65. $total = ceil($count / $size);
  66. $page = $page >= $total ? $total : $page;
  67. $list = Db::name('good_basic')->where($where)->page($page,$size)->order("addtime desc")->select();
  68. $data=[];
  69. foreach ($list as $value){
  70. $value["cat_info"]= made($value['cat_id'],[]);
  71. $brand=Db::name("brand")->where(["id"=>$value['brand_id']])->find();
  72. $value["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  73. $unit = Db::name("unit")->where(["id"=>$value['good_unit']])->find();
  74. $value['unit'] =isset($unit['unit'])?$unit['unit']:"";
  75. $company = Db::name("business")->where(["companyNo"=>$value['companyNo']])->find();
  76. $value['company'] = isset($company['company'])?$company['company']:"";
  77. $supplier = Db::name("supplier")->where(['code'=>$value['supplierNo']])->find();
  78. $value['supplier_name']=isset($supplier['name'])?$supplier['name']:"";
  79. $data[]=$value;
  80. }
  81. return app_show(0,"获取成功",['list'=>$data,'count'=>$count]);
  82. }
  83. public function create(){
  84. $good_name= isset($this->post['good_name'])&&$this->post['good_name']!="" ? trim($this->post['good_name']):"";
  85. if($good_name==""){
  86. return error_show(1004,"商品名称不能为空");
  87. }
  88. $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? intval($this->post['cat_id']):"";
  89. if($cat_id==''){
  90. return error_show(1004,"商品分类不能为空");
  91. }
  92. $brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):"";
  93. // if($brandid==''){
  94. // return error_show(1004,"商品品牌不能为空");
  95. // }
  96. $unit = isset($this->post['unit'])&&$this->post['unit']!=""? trim($this->post['unit']):"";
  97. if($unit==''){
  98. return error_show(1004,"商品单位不能为空");
  99. }
  100. $good_type = isset($this->post['good_type'])&&$this->post['good_type']!==""? intval($this->post['good_type'])
  101. :"";
  102. if($good_type===''){
  103. return error_show(1004,"参数good_type不能为空");
  104. }
  105. $moq=0;
  106. $customized=0;
  107. if($good_type==1){
  108. $moq = isset($this->post['moq'])&&$this->post['moq']!==""? intval($this->post['moq']):"";
  109. if($moq===''){
  110. return error_show(1004,"定制商品起订量不能为空");
  111. }
  112. $customized = isset($this->post['customized'])&&$this->post['customized']!==""? intval($this->post['customized']):"";
  113. if($customized===''){
  114. return error_show(1004,"参数customized不能为空");
  115. }
  116. }
  117. $is_exclusive = isset($this->post['is_exclusive'])&&$this->post['is_exclusive']!==""? intval($this->post['is_exclusive']):"";
  118. if($is_exclusive===''){
  119. return error_show(1004,"参数is_exclusive不能为空");
  120. }
  121. // $customized = isset($this->post['customized'])&&$this->post['customized']!==""? intval($this->post['customized']):"";
  122. // if($customized===''){
  123. // return error_show(1004,"参数customized不能为空");
  124. // }
  125. $tax = isset($this->post['tax'])&&$this->post['tax']!==""? intval($this->post['tax']):"";
  126. if($tax===''){
  127. return error_show(1004,"参数tax不能为空");
  128. }
  129. $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
  130. if($supplierNo==''){
  131. return error_show(1004,"参数supplierNo不能为空");
  132. }
  133. $company_id = isset($this->post['company_id'])&&$this->post['company_id']!=""? trim($this->post['company_id'])
  134. :"";
  135. if($company_id==''){
  136. return error_show(1004,"参数company_id不能为空");
  137. }
  138. $is_auth = isset($this->post['is_auth'])&&$this->post['is_auth']!==""? intval($this->post['is_auth']):"";
  139. if($is_auth===''){
  140. return error_show(1004,"参数is_auth不能为空");
  141. }
  142. $auth_img = isset($this->post['auth_img'])&&$this->post['auth_img']!=""? trim($this->post['auth_img']):"";
  143. // if($auth_img==''){
  144. // return error_show(1004,"商品不能为空");
  145. // }
  146. $after_sales = isset($this->post['after_sales'])&&$this->post['after_sales']!=""? trim($this->post['after_sales']):"";
  147. if($after_sales==""){
  148. return error_show(1004,"参数after_sales不能为空");
  149. }
  150. $craft_desc = isset($this->post['craft_desc'])&&$this->post['craft_desc']!=""? trim($this->post['craft_desc']):"";
  151. $good_remark = isset($this->post['good_remark'])&&$this->post['good_remark']!=""? trim($this->post['good_remark']):"";
  152. if($good_remark===""){
  153. return error_show(1004,"参数good_remark不能为空");
  154. }
  155. $weight = isset($this->post['weight'])&&$this->post['weight']!==""? floatval($this->post['weight']):"";
  156. if($weight===""){
  157. return error_show(1004,"参数weight不能为空");
  158. }
  159. $packing_way = isset($this->post['packing_way'])&&$this->post['packing_way']!==""? trim($this->post['packing_way']):"";
  160. if($packing_way===""){
  161. return error_show(1004,"参数packing_way不能为空");
  162. }
  163. $packing_size = isset($this->post['packing_size'])&&$this->post['packing_size']!==""? trim($this->post['packing_size']):"";
  164. if($packing_size===""){
  165. return error_show(1004,"参数packing_size不能为空");
  166. }
  167. $packing_spec = isset($this->post['packing_spec'])&&$this->post['packing_spec']!==""? trim($this->post['packing_spec']):"";
  168. if($packing_spec===""){
  169. return error_show(1004,"参数packing_spec不能为空");
  170. }
  171. $packing_weight = isset($this->post['packing_weight'])&&$this->post['packing_weight']!==""? floatval($this->post['packing_weight']):"";
  172. if($packing_weight===""){
  173. return error_show(1004,"参数packing_weight不能为空");
  174. }
  175. $packing_list = isset($this->post['packing_list'])&&$this->post['packing_list']!==""? trim($this->post['packing_list']):"";
  176. if($packing_list===""){
  177. return error_show(1004,"参数packing_list不能为空");
  178. }
  179. $good_bar = isset($this->post['good_bar'])&&$this->post['good_bar']!==""? trim($this->post['good_bar']):"";
  180. $supply_area = isset($this->post['supply_area'])&&$this->post['supply_area']!==""? intval($this->post['supply_area']):"";
  181. if($supply_area===""){
  182. return error_show(1004,"参数supply_area不能为空");
  183. }
  184. $delivery_place = isset($this->post['delivery_place'])&&$this->post['delivery_place']!==""? trim($this->post['delivery_place']):"";
  185. if($delivery_place===""){
  186. return error_show(1004,"参数delivery_place不能为空");
  187. }
  188. $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!==""? trim($this->post['origin_place']):"";
  189. if($origin_place===""){
  190. return error_show(1004,"参数origin_place不能为空");
  191. }
  192. $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!==""? intval($this->post['delivery_day']):"";
  193. if($delivery_day===""){
  194. return error_show(1004,"参数delivery_day不能为空");
  195. }
  196. $lead_time = isset($this->post['lead_time'])&&$this->post['lead_time']!==""? intval($this->post['lead_time'])
  197. :"0";
  198. // if($lead_time===""){
  199. // return error_show(1004,"参数lead_time不能为空");
  200. // }
  201. $sample_day = isset($this->post['sample_day'])&&$this->post['sample_day']!==""? intval($this->post['sample_day']):"0";
  202. // if($sample_day===""){
  203. // return error_show(1004,"参数sample_day不能为空");
  204. // }
  205. $sample_fee = isset($this->post['sample_fee'])&&$this->post['sample_fee']!==""? floatval($this->post['sample_fee']):"0";
  206. $is_stock = isset($this->post['is_stock'])&&$this->post['is_stock']!==""? intval($this->post['is_stock']):"";
  207. if($is_stock===""){
  208. return error_show(1004,"参数is_stock不能为空");
  209. }
  210. $good_img = isset($this->post['good_img'])&&$this->post['good_img']!==""? trim($this->post['good_img']):"";
  211. // if($good_img===""){
  212. // return error_show(1004,"参数good_img不能为空");
  213. // }
  214. $good_thumb_img = isset($this->post['good_thumb_img'])&&$this->post['good_thumb_img']!==""? trim($this->post['good_thumb_img']):"";
  215. if($good_thumb_img===""){
  216. return error_show(1004,"参数good_thumb_img不能为空");
  217. }
  218. $good_info_img = isset($this->post['good_info_img'])&&!empty($this->post['good_info_img'])? $this->post['good_info_img']:"";
  219. if($good_info_img===""){
  220. return error_show(1004,"参数good_info_img不能为空");
  221. }
  222. $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!==""? floatval($this->post['cert_fee']):"0";
  223. $packing_fee = isset($this->post['packing_fee'])&&$this->post['packing_fee']!==""? floatval($this->post['packing_fee']):"0";
  224. $cost_fee = isset($this->post['cost_fee'])&&$this->post['cost_fee']!==""? floatval($this->post['cost_fee']):"0";
  225. $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!==""? floatval($this->post['mark_fee']):"0";
  226. $demo_fee = isset($this->post['demo_fee'])&&$this->post['demo_fee']!==""? floatval($this->post['demo_fee']):"0";
  227. $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!==""? floatval($this->post['open_fee']):"0";
  228. $noble_metal = isset($this->post['noble_metal'])&&$this->post['noble_metal']!==""? intval($this->post['noble_metal']):"0";
  229. $noble_weight = isset($this->post['noble_weight'])&&$this->post['noble_weight']!==""? floatval($this->post['noble_weight']):"0";
  230. $is_gold_price= isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!==""? intval($this->post['is_gold_price']):"0";
  231. $market_price = isset($this->post['market_price'])&&$this->post['market_price']!==""? floatval($this->post['market_price']):"";
  232. if($market_price===""){
  233. return error_show(1004,"参数market_price不能为空");
  234. }
  235. $nake_price = isset($this->post['nake_price'])&&$this->post['nake_price']!==""? floatval($this->post['nake_price']):"";
  236. if($nake_price===""){
  237. return error_show(1004,"参数nake_price不能为空");
  238. }
  239. $is_step = isset($this->post['is_step'])&&$this->post['is_step']!==""? intval($this->post['is_step']):"";
  240. if($is_step===""){
  241. return error_show(1004,"参数is_step不能为空");
  242. }
  243. $speclist = isset($this->post['speclist'])&&!empty($this->post['speclist'])? $this->post['speclist']:"";
  244. $good_ladder = isset($this->post['good_ladder'])&&!empty($this->post['good_ladder'])? $this->post['good_ladder']:"";
  245. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  246. if($token==''){
  247. return error_show(1005,"参数token不能为空");
  248. }
  249. $user =GetUserInfo($token);
  250. if(empty($user)||$user['code']!=0){
  251. return error_show(1002,"创建人数据不存在");
  252. }
  253. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  254. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  255. $spucode=makeNo("SPU");
  256. Db::startTrans();
  257. try {
  258. $data=[
  259. "spuCode"=>$spucode,
  260. "good_code"=>'',
  261. "good_name"=>$good_name,
  262. "cat_id"=>$cat_id,
  263. 'brand_id'=>$brandid,
  264. "good_unit"=>$unit,
  265. "good_type"=>$good_type,
  266. "moq"=>$moq,
  267. "is_exclusive"=>$is_exclusive,
  268. "customized"=>$customized,
  269. "companyNo"=>$company_id,
  270. "tax"=>$tax,
  271. "supplierNo"=>$supplierNo,
  272. "is_auth"=>$is_auth,
  273. "is_stock"=>$is_stock,
  274. "auth_img"=>$auth_img,
  275. "after_sales"=>$after_sales,
  276. "craft_desc"=>$craft_desc,
  277. "good_remark"=>$good_remark,
  278. "weight"=>$weight,
  279. "packing_way"=>$packing_way,
  280. "packing_size"=>$packing_size,
  281. "packing_spec"=>$packing_spec,
  282. "packing_list"=>$packing_list,
  283. "packing_weight"=>$packing_weight,
  284. "good_bar"=>$good_bar,
  285. "supply_area"=>$supply_area,
  286. "delivery_place"=>$delivery_place,
  287. "origin_place"=>$origin_place,
  288. "delivery_day"=>$delivery_day,
  289. "lead_time"=>$lead_time,
  290. "sample_day"=>$sample_day,
  291. "sample_fee"=>$sample_fee,
  292. "good_img"=>$good_img,
  293. "good_thumb_img"=>$good_thumb_img,
  294. "good_info_img"=>json_encode($good_info_img),
  295. "cert_fee"=>$cert_fee,
  296. "packing_fee"=>$packing_fee,
  297. "cost_fee"=>$cost_fee,
  298. "mark_fee"=>$mark_fee,
  299. "demo_fee"=>$demo_fee,
  300. "open_fee"=>$open_fee,
  301. "noble_metal"=>$noble_metal,
  302. "noble_weight"=>$noble_weight,
  303. "is_gold_price"=>$is_gold_price,
  304. "market_price"=>$market_price,
  305. "nake_price"=>$nake_price,
  306. "is_step"=>$is_step,
  307. "is_online"=>0,
  308. "status"=>0,
  309. "createrid"=>$createrid,
  310. "creater"=>$creater,
  311. "addtime"=>date("Y-m-d H:i:s"),
  312. "updatetime"=>date("Y-m-d H:i:s")
  313. ];
  314. $in = Db::name("good_basic")->insert($data);
  315. if($in){
  316. if($speclist!=="" && !empty($speclist)){
  317. $temp=[];
  318. foreach ($speclist as $value){
  319. $lemp=[];
  320. $lemp['spuCode']=$spucode;
  321. $lemp['spec_id'] = $value['spec_id'];
  322. $lemp['spec_value_id'] = $value['spec_value_id'];
  323. $lemp['addtime'] = date("Y-m-d H:i:s");
  324. $lemp['updatetime'] =date("Y-m-d H:i:s");
  325. $temp[]=$lemp;
  326. }
  327. $count = Db::name("good_spec")->insertAll($temp);
  328. if($count==0){
  329. Db::rollback();
  330. return app_show(1004,"商品规格值创建失败");
  331. }
  332. }
  333. if($good_ladder!=="" && !empty($good_ladder)){
  334. $temp=[];
  335. foreach ($good_ladder as $value){
  336. $lemp=[];
  337. $lemp['spuCode']=$spucode;
  338. $lemp['min_num'] = $value['min_num'];
  339. $lemp['nake_fee'] = $value['nake_fee'];
  340. $lemp['cost_fee'] = $value['cost_fee'];
  341. $lemp['delivery_fee'] = $value['delivery_fee'];
  342. $lemp['is_del'] = 0;
  343. $lemp['addtime'] = date("Y-m-d H:i:s");
  344. $lemp['updatetime'] =date("Y-m-d H:i:s");
  345. $temp[]=$lemp;
  346. }
  347. $count = Db::name("good_nake")->insertAll($temp);
  348. if($count==0){
  349. Db::rollback();
  350. return app_show(1004,"商品规格值创建失败");
  351. }
  352. }
  353. Db::commit();
  354. return app_show(0,"创建成功",["spuCode"=>$spucode]);
  355. }else{
  356. Db::rollback();
  357. return app_show(1004,"商品创建失败");
  358. }
  359. }catch (\Exception $e){
  360. Db::rollback();
  361. return app_show(1004,$e->getMessage());
  362. }
  363. }
  364. public function editinfo(){
  365. $supcode = isset($this->post['spuCode'])&&$this->post['spuCode']!="" ? trim($this->post['spuCode']):"";
  366. if($supcode==""){
  367. return error_show(1004,"参数spuCode不能为空");
  368. }
  369. $data = Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->find();
  370. if($data==false){
  371. return error_show(1004,"未找到商品数据");
  372. }
  373. $good_name= isset($this->post['good_name'])&&$this->post['good_name']!="" ? trim($this->post['good_name']):"";
  374. if($good_name==""){
  375. return error_show(1004,"商品名称不能为空");
  376. }
  377. $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? intval($this->post['cat_id']):"";
  378. if($cat_id==''){
  379. return error_show(1004,"商品分类不能为空");
  380. }
  381. $brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):"0";
  382. // if($brandid==''){
  383. // return error_show(1004,"商品品牌不能为空");
  384. // }
  385. $unit = isset($this->post['unit'])&&$this->post['unit']!=""? trim($this->post['unit']):"";
  386. if($unit==''){
  387. return error_show(1004,"商品单位不能为空");
  388. }
  389. $good_type = isset($this->post['good_type'])&&$this->post['good_type']!==""? intval($this->post['good_type'])
  390. :"";
  391. if($good_type===''){
  392. return error_show(1004,"参数good_type不能为空");
  393. }
  394. $moq=0;
  395. $customized=0;
  396. if($good_type==1){
  397. $moq = isset($this->post['moq'])&&$this->post['moq']!==""? intval($this->post['moq']):"";
  398. if($moq===''){
  399. return error_show(1004,"定制商品起订量不能为空");
  400. }
  401. $customized = isset($this->post['customized'])&&$this->post['customized']!==""? intval($this->post['customized']):"";
  402. if($customized===''){
  403. return error_show(1004,"参数customized不能为空");
  404. }
  405. }
  406. $is_exclusive = isset($this->post['is_exclusive'])&&$this->post['is_exclusive']!==""? intval($this->post['is_exclusive']):"";
  407. if($is_exclusive===''){
  408. return error_show(1004,"参数is_exclusive不能为空");
  409. }
  410. // $customized = isset($this->post['customized'])&&$this->post['customized']!==""? intval($this->post['customized']):"";
  411. // if($customized===''){
  412. // return error_show(1004,"参数customized不能为空");
  413. // }
  414. $tax = isset($this->post['tax'])&&$this->post['tax']!==""? intval($this->post['tax']):"";
  415. if($tax===''){
  416. return error_show(1004,"参数tax不能为空");
  417. }
  418. $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
  419. if($supplierNo==''){
  420. return error_show(1004,"参数supplierNo不能为空");
  421. }
  422. $company_id = isset($this->post['company_id'])&&$this->post['company_id']!=""? trim($this->post['company_id'])
  423. :"";
  424. if($company_id==''){
  425. return error_show(1004,"参数company_id不能为空");
  426. }
  427. $is_auth = isset($this->post['is_auth'])&&$this->post['is_auth']!==""? intval($this->post['is_auth']):"";
  428. if($is_auth===''){
  429. return error_show(1004,"参数is_auth不能为空");
  430. }
  431. $auth_img = isset($this->post['auth_img'])&&$this->post['auth_img']!=""? trim($this->post['auth_img']):"";
  432. // if($auth_img==''){
  433. // return error_show(1004,"商品不能为空");
  434. // }
  435. $after_sales = isset($this->post['after_sales'])&&$this->post['after_sales']!=""? trim($this->post['after_sales']):"";
  436. if($after_sales==""){
  437. return error_show(1004,"参数after_sales不能为空");
  438. }
  439. $craft_desc = isset($this->post['craft_desc'])&&$this->post['craft_desc']!=""? trim($this->post['craft_desc']):"";
  440. $good_remark = isset($this->post['good_remark'])&&$this->post['good_remark']!=""? trim($this->post['good_remark']):"";
  441. if($good_remark===""){
  442. return error_show(1004,"参数good_remark不能为空");
  443. }
  444. $weight = isset($this->post['weight'])&&$this->post['weight']!==""? floatval($this->post['weight']):"";
  445. if($weight===""){
  446. return error_show(1004,"参数weight不能为空");
  447. }
  448. $packing_way = isset($this->post['packing_way'])&&$this->post['packing_way']!==""? trim($this->post['packing_way']):"";
  449. if($packing_way===""){
  450. return error_show(1004,"参数packing_way不能为空");
  451. }
  452. $packing_size = isset($this->post['packing_size'])&&$this->post['packing_size']!==""? trim($this->post['packing_size']):"";
  453. if($packing_size===""){
  454. return error_show(1004,"参数packing_size不能为空");
  455. }
  456. $packing_spec = isset($this->post['packing_spec'])&&$this->post['packing_spec']!==""? trim($this->post['packing_spec']):"";
  457. if($packing_spec===""){
  458. return error_show(1004,"参数packing_spec不能为空");
  459. }
  460. $packing_weight = isset($this->post['packing_weight'])&&$this->post['packing_weight']!==""? floatval($this->post['packing_weight']):"";
  461. if($packing_weight===""){
  462. return error_show(1004,"参数packing_weight不能为空");
  463. }
  464. $packing_list = isset($this->post['packing_list'])&&$this->post['packing_list']!==""? trim($this->post['packing_list']):"";
  465. if($packing_list===""){
  466. return error_show(1004,"参数packing_list不能为空");
  467. }
  468. $good_bar = isset($this->post['good_bar'])&&$this->post['good_bar']!==""? trim($this->post['good_bar']):"";
  469. $supply_area = isset($this->post['supply_area'])&&$this->post['supply_area']!==""? intval($this->post['supply_area']):"";
  470. if($supply_area===""){
  471. return error_show(1004,"参数supply_area不能为空");
  472. }
  473. $delivery_place = isset($this->post['delivery_place'])&&$this->post['delivery_place']!==""? $this->post['delivery_place']:"";
  474. if($delivery_place===""){
  475. return error_show(1004,"参数delivery_place不能为空");
  476. }
  477. $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!==""? $this->post['origin_place']:"";
  478. if($origin_place===""){
  479. return error_show(1004,"参数origin_place不能为空");
  480. }
  481. $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!==""? intval($this->post['delivery_day']):"";
  482. if($delivery_day===""){
  483. return error_show(1004,"参数delivery_day不能为空");
  484. }
  485. $lead_time = isset($this->post['lead_time'])&&$this->post['lead_time']!==""? intval($this->post['lead_time'])
  486. :"0";
  487. // if($lead_time===""){
  488. // return error_show(1004,"参数lead_time不能为空");
  489. // }
  490. $sample_day = isset($this->post['sample_day'])&&$this->post['sample_day']!==""? intval($this->post['sample_day']):"0";
  491. // if($sample_day===""){
  492. // return error_show(1004,"参数sample_day不能为空");
  493. // }
  494. $sample_fee = isset($this->post['sample_fee'])&&$this->post['sample_fee']!==""? floatval($this->post['sample_fee']):"0";
  495. $good_img = isset($this->post['good_img'])&&$this->post['good_img']!==""? trim($this->post['good_img']):"";
  496. // if($good_img===""){
  497. // return error_show(1004,"参数good_img不能为空");
  498. // }
  499. $good_thumb_img = isset($this->post['good_thumb_img'])&&$this->post['good_thumb_img']!==""? trim($this->post['good_thumb_img']):"";
  500. if($good_thumb_img===""){
  501. return error_show(1004,"参数good_thumb_img不能为空");
  502. }
  503. $good_info_img = isset($this->post['good_info_img'])&&!empty($this->post['good_info_img'])? $this->post['good_info_img']:"";
  504. if($good_info_img===""){
  505. return error_show(1004,"参数good_info_img不能为空");
  506. }
  507. $speclist = isset($this->post['speclist'])&&!empty($this->post['speclist'])? $this->post['speclist']:"";
  508. Db::startTrans();
  509. try {
  510. $temp=[
  511. "good_name"=>$good_name,
  512. "cat_id"=>$cat_id,
  513. 'brand_id'=>$brandid,
  514. "good_unit"=>$unit,
  515. "good_type"=>$good_type,
  516. "companyNo"=>$company_id,
  517. "moq"=>$moq,
  518. "is_exclusive"=>$is_exclusive,
  519. "customized"=>$customized,
  520. "tax"=>$tax,
  521. "supplierNo"=>$supplierNo,
  522. "is_auth"=>$is_auth,
  523. "auth_img"=>$auth_img,
  524. "after_sales"=>$after_sales,
  525. "craft_desc"=>$craft_desc,
  526. "good_remark"=>$good_remark,
  527. "weight"=>$weight,
  528. "packing_way"=>$packing_way,
  529. "packing_size"=>$packing_size,
  530. "packing_spec"=>$packing_spec,
  531. "packing_list"=>$packing_list,
  532. "packing_weight"=>$packing_weight,
  533. "good_bar"=>$good_bar,
  534. "supply_area"=>$supply_area,
  535. "delivery_place"=>$delivery_place,
  536. "origin_place"=>$origin_place,
  537. "delivery_day"=>$delivery_day,
  538. "lead_time"=>$lead_time,
  539. "sample_day"=>$sample_day,
  540. "sample_fee"=>$sample_fee,
  541. "good_img"=>$good_img,
  542. "good_thumb_img"=>$good_thumb_img,
  543. "good_info_img"=>json_encode($good_info_img),
  544. "status"=>"3",
  545. "updatetime"=>date("Y-m-d H:i:s")
  546. ];
  547. $field = array_diff($temp,$data);
  548. $up = Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->save($temp);
  549. if($up){
  550. if($speclist!=="" && !empty($speclist)){
  551. foreach ($speclist as $value){
  552. $lemp=[];
  553. isset($value["id"])?$lemp['id']=$value['id']:"";
  554. $lemp['spuCode']=$supcode;
  555. $lemp['spec_id'] = $value['spec_id'];
  556. $lemp['spec_value_id'] = $value['spec_value_id'];
  557. $lemp['is_del'] = isset($value['is_del'])?$value['is_del']:0;
  558. isset($value["id"])? $lemp['addtime'] = date("Y-m-d H:i:s"):"";
  559. $lemp['updatetime'] =date("Y-m-d H:i:s");
  560. $count = Db::name("good_spec")->save($lemp);
  561. if($count==false){
  562. Db::rollback();
  563. return app_show(1004,"商品规格值修改失败");
  564. }
  565. }
  566. }
  567. Db::commit();
  568. return app_show(0,"更新成功");
  569. }else{
  570. Db::rollback();
  571. return error_show(1005,"更新失败");
  572. }
  573. }catch (\Exception $e){
  574. Db::rollback();
  575. return error_show(1004,$e->getMessage());
  576. }
  577. }
  578. public function editfee(){
  579. $supcode = isset($this->post['spuCode'])&&$this->post['spuCode']!="" ? trim($this->post['spuCode']):"";
  580. if($supcode==""){
  581. return error_show(1004,"参数spuCode不能为空");
  582. }
  583. $data = Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->find();
  584. if($data==false){
  585. return error_show(1004,"未找到商品数据");
  586. }
  587. $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!==""? floatval($this->post['cert_fee']):"0";
  588. $packing_fee = isset($this->post['packing_fee'])&&$this->post['packing_fee']!==""? floatval($this->post['packing_fee']):"0";
  589. $cost_fee = isset($this->post['cost_fee'])&&$this->post['cost_fee']!==""? floatval($this->post['cost_fee']):"0";
  590. $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!==""? floatval($this->post['mark_fee']):"0";
  591. $demo_fee = isset($this->post['demo_fee'])&&$this->post['demo_fee']!==""? floatval($this->post['demo_fee']):"0";
  592. $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!==""? floatval($this->post['open_fee']):"0";
  593. $noble_metal = isset($this->post['noble_metal'])&&$this->post['noble_metal']!==""? intval($this->post['noble_metal']):"0";
  594. $noble_weight = isset($this->post['noble_weight'])&&$this->post['noble_weight']!==""? floatval($this->post['noble_weight']):"0";
  595. $is_gold_price= isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!==""? intval($this->post['is_gold_price']):"0";
  596. $market_price = isset($this->post['market_price'])&&$this->post['market_price']!==""? floatval($this->post['market_price']):"";
  597. if($market_price===""){
  598. return error_show(1004,"参数market_price不能为空");
  599. }
  600. $nake_price = isset($this->post['nake_price'])&&$this->post['nake_price']!==""? floatval($this->post['nake_price']):"";
  601. if($nake_price===""){
  602. return error_show(1004,"参数nake_price不能为空");
  603. }
  604. $is_step = isset($this->post['is_step'])&&$this->post['is_step']!==""? intval($this->post['is_step']):"";
  605. if($is_step===""){
  606. return error_show(1004,"参数is_step不能为空");
  607. }
  608. $good_ladder = isset($this->post['good_ladder'])&&!empty($this->post['good_ladder'])? $this->post['good_ladder']:"";
  609. $data=[
  610. "cert_fee"=>$cert_fee,
  611. "packing_fee"=>$packing_fee,
  612. "cost_fee"=>$cost_fee,
  613. "mark_fee"=>$mark_fee,
  614. "demo_fee"=>$demo_fee,
  615. "open_fee"=>$open_fee,
  616. "noble_metal"=>$noble_metal,
  617. "noble_weight"=>$noble_weight,
  618. "is_gold_price"=>$is_gold_price,
  619. "market_price"=>$market_price,
  620. "nake_price"=>$nake_price,
  621. "is_step"=>$is_step,
  622. "status"=>"2",
  623. "updatetime"=>date("Y-m-d H:i:s")
  624. ];
  625. Db::startTrans();
  626. try{
  627. $up = Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->save($data);
  628. if($up){
  629. $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")]);
  630. if($good_ladder!=="" && !empty($good_ladder)){
  631. foreach ($good_ladder as $value){
  632. $lemp=[];
  633. isset($value["id"])?$lemp['id']=$value['id']:"";
  634. $lemp['spuCode']=$supcode;
  635. $lemp['min_num'] = $value['min_num'];
  636. $lemp['nake_fee'] = $value['nake_fee'];
  637. $lemp['cost_fee'] = $value['cost_fee'];
  638. $lemp['delivery_fee'] = $value['delivery_fee'];
  639. $lemp['is_del'] = isset($value['is_del'])?$value['is_del']:0;
  640. isset($value["id"])? $lemp['addtime'] = date("Y-m-d H:i:s"):"";
  641. $lemp['updatetime'] =date("Y-m-d H:i:s");
  642. $count = Db::name("good_nake")->save($lemp);
  643. if($count==false){
  644. Db::rollback();
  645. return app_show(1004,"商品规成本修改失败");
  646. }
  647. }
  648. }
  649. Db::commit();
  650. return app_show(0,"更新成功");
  651. }else{
  652. Db::rollback();
  653. return error_show(1005,"更新失败");
  654. }
  655. }catch (\Exception $e){
  656. Db::rollback();
  657. return error_show(1005,$e->getMessage());
  658. }
  659. }
  660. public function exam(){
  661. $supcode = isset($this->post['spuCode'])&&$this->post['spuCode']!="" ? trim($this->post['spuCode']):"";
  662. if($supcode==""){
  663. return error_show(1004,"参数spuCode不能为空");
  664. }
  665. $data = Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->find();
  666. if($data==false){
  667. return error_show(1004,"未找到商品数据");
  668. }
  669. if($data['status']==1){
  670. return error_show(1004,"商品已审核通过");
  671. }
  672. $status = isset($this->post['status'])&&$this->post['status']!=="" ? intval($this->post['status']):"";
  673. if($status===""){
  674. return error_show(1004,"参数status不能为空");
  675. }
  676. $remark = isset($this->post['remark'])&&$this->post['remark']!=="" ? trim($this->post['remark']):"";
  677. // if($remark===""){
  678. // return error_show(1004,"参数remark不能为空");
  679. // }
  680. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  681. if($token==''){
  682. return error_show(1005,"参数token不能为空");
  683. }
  684. $user =GetUserInfo($token);
  685. if(empty($user)||$user['code']!=0){
  686. return error_show(1002,"用户数据不存在");
  687. }
  688. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  689. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  690. Db::startTrans();
  691. try {
  692. if($data['status']==3){
  693. $online = Db::name("good_platform")->where(["spuCode"=>$supcode,"is_online"=>0,"status"=>0, "is_del"=>0])->save(["is_online"=>0,"status"=>2,"updatetime"=>date("Y-m-d H:i:s")]);
  694. }
  695. $data['status']=$status;
  696. $data['updatetime']=date("Y-m-d H:i:s");
  697. $up= Db::name("good_basic")->save($data);
  698. if($up){
  699. $data=[
  700. "code"=>$supcode,
  701. "exam_status"=>$status,
  702. "type"=>1,
  703. "exam_id"=>$createrid,
  704. "exam_name"=>$creater,
  705. "exam_remark"=>$remark,
  706. "addtime"=>date("Y-m-d H:i:s")
  707. ];
  708. $inr=Db::name("good_exam")->insert($data);
  709. if($inr){
  710. Db::commit();
  711. return app_show(0,"审核成功");
  712. }else{
  713. Db::rollback();
  714. return error_show(1004,"审核失败");
  715. }
  716. }else{
  717. Db::rollback();
  718. return error_show(1004,"审核失败");
  719. }
  720. }catch (\Exception $e){
  721. Db::rollback();
  722. return error_show(1004,$e->getMessage());
  723. }
  724. }
  725. public function info(){
  726. $supcode = isset($this->post['spuCode'])&&$this->post['spuCode']!="" ? trim($this->post['spuCode']):"";
  727. if($supcode==""){
  728. return error_show(1004,"参数spuCode不能为空");
  729. }
  730. $data = Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->find();
  731. if($data==false){
  732. return error_show(1004,"未找到商品数据");
  733. }
  734. $unit =Db::name("unit")->where(["id"=>$data['good_unit']])->find();
  735. $data['unit'] = isset($unit['unit'])?$unit['unit']:'';
  736. $data['cat_info'] = made($data['cat_id'],[]);
  737. $spec = Db::name("good_spec")->where(["spuCode"=>$supcode,"is_del"=>0])->select()->toArray();
  738. $supplier = Db::name("supplier")->where(["code"=>$data['supplierNo']])->find();
  739. $data['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  740. $supplier = Db::name("supplier")->where(["code"=>$data['supplierNo']])->find();
  741. $data['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  742. $company = Db::name("business")->where(["companyNo"=>$data['companyNo']])->find();
  743. $data['company'] = isset($company['company'])?$company['company']:"";
  744. if($data['brand_id']!=0){
  745. $brand=Db::name("brand")->where(["id"=>$data['brand_id']])->find();
  746. $data["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  747. }else{
  748. $data["brand_name"]="";
  749. $data["brand_id"]="";
  750. }
  751. $data["good_info_img"]=$data['good_info_img']!=""? json_decode($data['good_info_img'],true):[];
  752. $speclist=[];
  753. if(!empty($spec)){
  754. foreach ($spec as $value){
  755. $temp=[];
  756. $temp['id']=$value['id'];
  757. $temp['spuCode']=$value['spuCode'];
  758. $temp['spec_id']=$value['spec_id'];
  759. $temp['spec_value_id']=$value['spec_value_id'];
  760. $temp['is_del']=$value['is_del'];
  761. $sp = Db::name("specs")->where(["id"=>$value['spec_id']])->find();
  762. $temp['spec_name']=isset($sp["spec_name"]) ? $sp["spec_name"]:"";
  763. $spv = Db::name("spec_value")->where(["id"=>$value['spec_value_id']])->find();
  764. $temp['spec_value']=isset($spv["spec_value"]) ? $spv["spec_value"]:"";
  765. $speclist[]=$temp;
  766. }
  767. }
  768. $data["speclist"]=empty($speclist)?[]:$speclist;
  769. // $nake=[];
  770. $nakelist = Db::name("good_nake")->where(['spuCode'=>$supcode,"is_del"=>0])->select()->toArray();
  771. $data["nakelist"]=!empty($nakelist)?$nakelist:[];
  772. return app_show(0,"获取成功",$data);
  773. }
  774. public function delall(){
  775. $supcode = isset($this->post['codes'])&&!empty($this->post['codes'])? $this->post['codes']:"";
  776. if($supcode==""){
  777. return error_show(1004,"参数codes不能为空");
  778. }
  779. $data = Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->select()->toArray();
  780. if(empty($data)){
  781. return error_show(1004,"未找到商品数据");
  782. }
  783. $up= Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->save(["is_del"=>1]);
  784. if($up){
  785. return app_show(0,"更新成功");
  786. }else{
  787. return error_show(1005,"更新失败");
  788. }
  789. }
  790. public function online(){
  791. $platform =isset($this->post['platform'])&&!empty($this->post['platform'])? $this->post['platform']:"";
  792. if($platform==""){
  793. return error_show(1004,"参数codes不能为空");
  794. }
  795. $spuCode =isset($this->post['codes'])&&!empty($this->post['codes'])? $this->post['codes']:"";
  796. if($spuCode===''){
  797. return error_show(1004,"参数codes不能为空");
  798. }
  799. $datas = Db::name("good_basic")->where(["spuCode"=>$spuCode,"is_del"=>0])->select()->toArray();
  800. if(empty($datas)){
  801. return error_show(1004,"未找到商品数据");
  802. }
  803. $online_reason = isset($this->post['online_reason'])&&$this->post['online_reason']!==""? trim($this->post['online_reason']):"";
  804. if($online_reason===""){
  805. return error_show(1004,"参数online_reason不能为空");
  806. }
  807. $online_remark= isset($this->post['online_remark'])&&$this->post['online_remark']!==""? trim($this->post['online_remark']):"";
  808. if($online_remark===""){
  809. return error_show(1004,"参数online_remark不能为空");
  810. }
  811. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  812. if($token==''){
  813. return error_show(1005,"参数token不能为空");
  814. }
  815. $user =GetUserInfo($token);
  816. if(empty($user)||$user['code']!=0){
  817. return error_show(1002,"用户数据不存在");
  818. }
  819. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  820. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  821. $data=[];
  822. foreach ($spuCode as $value){
  823. $count = Db::name("good_nake")->where(["spuCode"=>$value,"is_del"=>0])->count();
  824. $data[]=[
  825. "spuCode"=>$value,
  826. "skuCode"=>makeNo("SKU"),
  827. "platform_code"=>$platform,
  828. "online_reason"=>$online_reason,
  829. "online_remark"=>$online_remark,
  830. "exam_status"=>$count>0 ?3:2,
  831. "is_online"=>0,
  832. "status"=>1,
  833. "is_del"=>0,
  834. "creater"=>$creater,
  835. "createrid"=>$createrid,
  836. "addtime"=>date("Y-m-d H:i:s"),
  837. "updatetime"=>date("Y-m-d H:i:s")
  838. ];
  839. }
  840. Db::startTrans();
  841. $create =Db::name("good_platform")->insertAll($data);
  842. if($create){
  843. foreach ($datas as $value){
  844. $iso = Db::name("good")->where(["spuCode"=>$value['spuCode'],"is_del"=>0])->find();
  845. if($iso==false){
  846. unset($value['id']);
  847. $value['creater']=$creater;
  848. $value['createrid']=$createrid;
  849. $value['addtime']=date("Y-m-d H:i:s");
  850. $value['updatetime']=date("Y-m-d H:i:s");
  851. }else{
  852. $value['id']=$iso['id'];
  853. $value['creater']=$creater;
  854. $value['createrid']=$createrid;
  855. $value['updatetime']=date("Y-m-d H:i:s");
  856. }
  857. $up =Db::name("good")->save($value);
  858. if(!$up){
  859. Db::rollback();
  860. return error_show(1004,"提交失败");
  861. }
  862. }
  863. Db::commit();
  864. return app_show(0,"提交成功");
  865. }else{
  866. Db::rollback();
  867. return error_show(1004,"提交失败");
  868. }
  869. }
  870. public function online_exam(){
  871. $skuCode = isset($this->post['skuCode'])&&$this->post['skuCode']!==""?trim($this->post['skuCode']):"";
  872. if($skuCode===""){
  873. return error_show(1004,"参数skuCode不能为空");
  874. }
  875. $platform = Db::name("good_platform")->where(["skuCode"=>$skuCode,"is_del"=>0])->find();
  876. if($platform==false){
  877. return error_show(1004,"未找到数据");
  878. }
  879. $exam_status=isset($this->post['exam_status'])&&$this->post['exam_status']!==""?intval($this->post['exam_status']):"";
  880. if($exam_status===""){
  881. return error_show(1004,"参数exam_status不能为空");
  882. }
  883. if($exam_status==3){
  884. $online_time= isset($this->post['online_time'])&&$this->post['online_time']!==""?$this->post['online_time']:"";
  885. if($online_time===""){
  886. return error_show(1004,"参数online_time不能为空");
  887. }
  888. $platform['online_time']=$online_time;
  889. }
  890. $exam_remark = isset($this->post['exam_remark'])&&$this->post['exam_remark']!==""?trim($this->post['exam_remark']):"";
  891. $platform['exam_status']=$exam_status;
  892. $platform['updatetime']=date("Y-m-d H:i:s");
  893. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  894. if($token==''){
  895. return error_show(1005,"参数token不能为空");
  896. }
  897. $user =GetUserInfo($token);
  898. if(empty($user)||$user['code']!=0){
  899. return error_show(1002,"用户数据不存在");
  900. }
  901. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  902. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  903. Db::startTrans();
  904. try {
  905. $up = Db::name("good_platform")->save($platform);
  906. if($up){
  907. $data=[
  908. "code"=>$platform['skuCode'],
  909. "exam_status"=>$exam_status,
  910. "type"=>2,
  911. "exam_id"=>$createrid,
  912. "exam_name"=>$creater,
  913. "exam_remark"=>$exam_remark,
  914. "addtime"=>date("Y-m-d H:i:s")
  915. ];
  916. $inr=Db::name("good_exam")->insert($data);
  917. if($inr){
  918. Db::commit();
  919. return app_show(0,"审核成功");
  920. }else{
  921. Db::rollback();
  922. return error_show(1004,"审核失败");
  923. }
  924. }else{
  925. Db::rollback();
  926. return error_show(1004,"审核失败");
  927. }
  928. }catch (\Exception $e){
  929. Db::rollback();
  930. return error_show(1004,$e->getMessage());
  931. }
  932. }
  933. public function editladder(){
  934. $skuCode = isset($this->post['skuCode'])&&$this->post['skuCode']!==""?trim($this->post['skuCode']):"";
  935. if($skuCode===""){
  936. return error_show(1004,"参数skuCode不能为空");
  937. }
  938. $platform = Db::name("good_platform")->where(["skuCode"=>$skuCode,"is_del"=>0])->find();
  939. if($platform==false){
  940. return error_show(1004,"未找到数据");
  941. }
  942. $good_ladder = isset($this->post['good_ladder'])&&!empty($this->post['good_ladder'])?$this->post['good_ladder']:"";
  943. if($good_ladder==""){
  944. return error_show(1004,"参数good_ladder不能为空");
  945. }
  946. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  947. if($token==''){
  948. return error_show(1005,"参数token不能为空");
  949. }
  950. $user =GetUserInfo($token);
  951. if(empty($user)||$user['code']!=0){
  952. return error_show(1002,"用户数据不存在");
  953. }
  954. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  955. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  956. $platform['exam_status']=4;
  957. $platform['updatetime']=date("Y-m-d H:i:s");
  958. Db::startTrans();
  959. try {
  960. foreach ($good_ladder as $value){
  961. $lemp=[];
  962. isset($value["id"])&&$value["id"]!=""?$lemp['id']=$value['id']:"";
  963. $lemp['skuCode']=$skuCode;
  964. $lemp['min_num'] = $value['min_num'];
  965. $lemp['max_num'] = 0;
  966. $lemp['sale_price'] = $value['sale_price'];
  967. $lemp['origin_price'] = $value['origin_price'];
  968. $lemp['market_price'] = $value['market_price'];
  969. $lemp['market_platform'] = $value['market_platform'];
  970. $lemp['origin_rate'] = $value['origin_rate'];
  971. $lemp['status'] = $value['status'];
  972. $lemp['is_del'] = isset($value['is_del'])?$value['is_del']:0;
  973. isset($value["id"])&&$value["id"]!=""?"": $lemp['addtime'] = date("Y-m-d H:i:s");
  974. $lemp['updatetime'] =date("Y-m-d H:i:s");
  975. // var_dump(isset($value["id"]));
  976. $count = Db::name("good_ladder")->save($lemp);
  977. if($count==false){
  978. Db::rollback();
  979. return app_show(1004,"商品起订价修改失败");
  980. }
  981. }
  982. $up = Db::name("good_platform")->save($platform);
  983. if($up){
  984. $data=[
  985. "code"=>$platform['skuCode'],
  986. "type"=>2,
  987. "exam_status"=>4,
  988. "exam_id"=>$createrid,
  989. "exam_name"=>$creater,
  990. "exam_remark"=>'',
  991. "addtime"=>date("Y-m-d H:i:s")
  992. ];
  993. $inr=Db::name("good_exam")->insert($data);
  994. if($inr){
  995. Db::commit();
  996. return app_show(0,"审核成功");
  997. }else{
  998. Db::rollback();
  999. return error_show(1004,"审核失败");
  1000. }
  1001. }else{
  1002. Db::rollback();
  1003. return error_show(1004,"审核失败");
  1004. }
  1005. }catch (\Exception $e){
  1006. Db::rollback();
  1007. return error_show(1004,$e->getMessage());
  1008. }
  1009. }
  1010. }