Goodup.php 112 KB

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