Goodup.php 112 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211
  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])->save(["is_online"=>0,"status"=>0,"updatetime"=>date("Y-m-d H:i:s")]);
  770. if($good_ladder!=="" && !empty($good_ladder)){
  771. $user =GetUserInfo($this->post['token']);
  772. foreach ($good_ladder as $value){
  773. $lemp=[];
  774. isset($value["id"])&&$value["id"]!=''?$lemp['id']=$value['id']:"";
  775. $lemp['spuCode']=$supcode;
  776. $lemp['min_num'] = $value['min_num'];
  777. $lemp['nake_fee'] = $value['nake_fee'];
  778. $lemp['cost_fee'] = $value['cost_fee'];
  779. $lemp['delivery_fee'] = $value['delivery_fee'];
  780. $lemp['cert_fee'] = $value['cert_fee'];
  781. $lemp['mark_fee'] = $value['mark_fee'];
  782. $lemp['package_fee'] = $value['package_fee'];
  783. $lemp['other_fee'] = $value['other_fee'];
  784. if($is_gold_price==1 && $datas['cat_id']==6){
  785. //$gold =Db::name("gold_price1")->where(["type"=>$noble_metal,"status"=>1,"is_del"=>0])->order("addtime desc")->find();
  786. //$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'];
  787. //成本合计=贵金属重量*供应商采购金价 + 工艺费*贵金属重量+加标费+包装费+证书费+成本裸价+运费+其他费用
  788. //成本总计启用实时金价时,采用供应商实时金价
  789. $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'];
  790. }else{
  791. $lemp['nake_total'] =$value['nake_fee']+$value['delivery_fee']+$value['cert_fee']+$value['mark_fee']+$value['package_fee']+$value['other_fee'];
  792. }
  793. $lemp['is_del'] = isset($value['is_del'])?$value['is_del']:0;
  794. $lemp['creater_id'] = isset($user["data"]['id']) ? $user["data"]['id'] : "";
  795. $lemp['creater'] =isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  796. isset($value["id"])&&$value["id"]!=''?"": $lemp['addtime'] = date("Y-m-d H:i:s");
  797. $lemp['updatetime'] =date("Y-m-d H:i:s");
  798. $count = Db::name("good_nake")->save($lemp);
  799. if($count==false){
  800. Db::rollback();
  801. return app_show(1004,"商品规成本修改失败");
  802. }
  803. }
  804. }
  805. Db::commit();
  806. return app_show(0,"更新成功");
  807. }else{
  808. Db::rollback();
  809. return error_show(1005,"更新失败");
  810. }
  811. }catch (\Exception $e){
  812. Db::rollback();
  813. return error_show(1005,$e->getMessage());
  814. }
  815. }
  816. public function exam(){
  817. $supcode = isset($this->post['spuCode'])&&$this->post['spuCode']!="" ? trim($this->post['spuCode']):"";
  818. if($supcode==""){
  819. return error_show(1004,"参数spuCode不能为空");
  820. }
  821. $data = Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->find();
  822. if($data==false){
  823. return error_show(1004,"未找到商品数据");
  824. }
  825. if($data['status']==1){
  826. return error_show(1004,"商品已审核通过");
  827. }
  828. $status = isset($this->post['status'])&&$this->post['status']!=="" ? intval($this->post['status']):"";
  829. // if($status===""){
  830. // return error_show(1004,"参数status不能为空");
  831. // }
  832. $remark = isset($this->post['remark'])&&$this->post['remark']!=="" ? trim($this->post['remark']):"";
  833. // if($remark===""){
  834. // return error_show(1004,"参数remark不能为空");
  835. // }
  836. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  837. if($token==''){
  838. return error_show(105,"参数token不能为空");
  839. }
  840. $user =GetUserInfo($token);
  841. if(empty($user)||$user['code']!=0){
  842. return error_show(1002,"用户数据不存在");
  843. }
  844. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  845. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  846. Db::startTrans();
  847. try {
  848. if($data['status']==3 && $status==1){
  849. $online = Db::name("good_platform")->where(["spuCode"=>$supcode,"is_online"=>0,"status"=>0, "is_del"=>0])->save(["is_online"=>0,"exam_status"=>2,"updatetime"=>date("Y-m-d H:i:s")]);
  850. }
  851. if ($status == 1) {
  852. //把同一个spuCode,且状态为1待完善成本,的记录更改状态为2待产品审核
  853. Db::name('good')
  854. ->where(['is_del' => 0, 'status' => 1])
  855. ->whereIn('spuCode', $supcode)
  856. ->update(['status' => 2, 'updatetime' => date('Y-m-d H:i:s')]);
  857. }
  858. $data['status']=$status;
  859. $data['updatetime']=date("Y-m-d H:i:s");
  860. $up= Db::name("good_basic")->save($data);
  861. if($up){
  862. $data=[
  863. "code"=>$supcode,
  864. "exam_status"=>$status,
  865. "type"=>1,
  866. "exam_id"=>$createrid,
  867. "exam_name"=>$creater,
  868. "exam_remark"=>$remark,
  869. "addtime"=>date("Y-m-d H:i:s")
  870. ];
  871. $inr=Db::name("good_exam")->insert($data);
  872. if($inr){
  873. Db::commit();
  874. return app_show(0,"审核成功");
  875. }else{
  876. Db::rollback();
  877. return error_show(1004,"审核失败");
  878. }
  879. }else{
  880. Db::rollback();
  881. return error_show(1004,"审核失败");
  882. }
  883. }catch (\Exception $e){
  884. Db::rollback();
  885. return error_show(1004,$e->getMessage());
  886. }
  887. }
  888. public function info(){
  889. $supcode = isset($this->post['spuCode'])&&$this->post['spuCode']!="" ? trim($this->post['spuCode']):"";
  890. if($supcode==""){
  891. return error_show(1004,"参数spuCode不能为空");
  892. }
  893. $data = Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->find();
  894. if($data==false){
  895. return error_show(1004,"未找到商品数据");
  896. }
  897. $unit =Db::name("unit")->where(["id"=>$data['good_unit']])->find();
  898. $data['unit'] = isset($unit['unit'])?$unit['unit']:'';
  899. $data['cat_info'] = made($data['cat_id'],[]);
  900. $spec = Db::name("good_spec")->where(["spuCode"=>$supcode,"is_del"=>0])->select()->toArray();
  901. $supplier = Db::name("supplier")->where(["code"=>$data['supplierNo']])->find();
  902. $data['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  903. $supplier = Db::name("supplier")->where(["code"=>$data['supplierNo']])->find();
  904. $data['supplierName'] = isset($supplier['name'])?$supplier['name']:"";
  905. $company = Db::name("business")->where(["companyNo"=>$data['companyNo']])->find();
  906. $data['company'] = isset($company['company'])?$company['company']:"";
  907. $data['field_change'] = $data['field_change']!=''?json_decode($data['field_change']):"";
  908. if($data['brand_id']!=0){
  909. $brand=Db::name("brand")->where(["id"=>$data['brand_id']])->find();
  910. $data["brand_name"]=isset($brand['brand_name'])?$brand['brand_name']:"";
  911. }else{
  912. $data["brand_name"]="";
  913. $data["brand_id"]="";
  914. }
  915. $excluse = makeExcluse($data['is_exclusive']);
  916. $data['exclusive']=$excluse;
  917. $data['noble_name']=isset($data['noble_metal'])&&$data['noble_metal']!=0?$this->noble[$data['noble_metal']] :"";
  918. $data["good_info_img"]=$data['good_info_img']!=""? $data['good_info_img']:'';
  919. $data["good_img"]=$data['good_img']!=""? $data['good_img']:[];
  920. $gold=[];
  921. if ($data['is_gold_price'] == 1) {
  922. $gold = Db::name("gold_price1")->where(["type" => $data['noble_metal'], "status" => 1, "is_del" => 0])->order("addtime desc")->find();
  923. }
  924. $data['gold_price'] =isset($gold["price"])?$gold["price"]:0;
  925. $speclist=[];
  926. if(!empty($spec)){
  927. foreach ($spec as $value){
  928. $temp=[];
  929. $temp['id']=$value['id'];
  930. $temp['spuCode']=$value['spuCode'];
  931. $temp['spec_id']=$value['spec_id'];
  932. $temp['spec_value_id']=$value['spec_value_id'];
  933. $temp['is_del']=$value['is_del'];
  934. $sp = Db::name("specs")->where(["id"=>$value['spec_id']])->find();
  935. $temp['spec_name']=isset($sp["spec_name"]) ? $sp["spec_name"]:"";
  936. $spv = Db::name("spec_value")->where(["id"=>$value['spec_value_id']])->find();
  937. $temp['spec_value']=isset($spv["spec_value"]) ? $spv["spec_value"]:"";
  938. $speclist[]=$temp;
  939. }
  940. }
  941. $data["speclist"]=empty($speclist)?[]:$speclist;
  942. // $nake=[];
  943. $nakelist = Db::name("good_nake")->where(['spuCode'=>$supcode,"is_del"=>0])->select()->toArray();
  944. // $catinfo = Db::name("cat")->where(["id"=>$data['cat_id']])->find();
  945. // $budget = isset($catinfo['order_rate']) ? $catinfo['order_rate']/100:0;
  946. $nakearry=[];
  947. if(!empty($nakelist)){
  948. foreach ($nakelist as $value) {
  949. $nakearry[] = $value;
  950. }
  951. }
  952. $data["nakelist"]=$nakearry;
  953. return app_show(0,"获取成功",$data);
  954. }
  955. public function delall(){
  956. $supcode = isset($this->post['codes'])&&!empty($this->post['codes'])? $this->post['codes']:"";
  957. if($supcode==""){
  958. return error_show(1004,"参数codes不能为空");
  959. }
  960. $data = Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->select()->toArray();
  961. if(empty($data)){
  962. return error_show(1004,"未找到商品数据");
  963. }
  964. $up= Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->save(["is_del"=>1]);
  965. if($up){
  966. return app_show(0,"更新成功");
  967. }else{
  968. return error_show(1005,"更新失败");
  969. }
  970. }
  971. //添加上线商品
  972. public function online(){
  973. $platform =isset($this->post['platform'])&&!empty($this->post['platform'])? $this->post['platform']:"";
  974. if($platform==""){
  975. return error_show(1004,"参数codes不能为空");
  976. }
  977. $spuCode =isset($this->post['codes'])&&!empty($this->post['codes'])? $this->post['codes']:"";
  978. if($spuCode===''){
  979. return error_show(1004,"参数codes不能为空");
  980. }
  981. $datas = Db::name("good_basic")->where(["spuCode"=>$spuCode,"is_del"=>0])->select()->toArray();
  982. if(empty($datas)){
  983. return error_show(1004,"未找到商品数据");
  984. }
  985. $online_reason = isset($this->post['online_reason'])&&$this->post['online_reason']!==""? trim($this->post['online_reason']):"";
  986. if($online_reason===""){
  987. return error_show(1004,"参数online_reason不能为空");
  988. }
  989. $online_remark= isset($this->post['online_remark'])&&$this->post['online_remark']!==""? trim($this->post['online_remark']):"";
  990. if($online_remark===""){
  991. return error_show(1004,"参数online_remark不能为空");
  992. }
  993. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  994. if($token==''){
  995. return error_show(105,"参数token不能为空");
  996. }
  997. $user =GetUserInfo($token);
  998. if(empty($user)||$user['code']!=0){
  999. return error_show(1002,"用户数据不存在");
  1000. }
  1001. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1002. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1003. $data=[];
  1004. $isonline=[];
  1005. $i=0;
  1006. foreach ($spuCode as $value){
  1007. $count = Db::name("good_nake")->where(["spuCode"=>$value,"is_del"=>0])->count();
  1008. $ist =Db::name("good_platform")->where(["spuCode"=>$value,"platform_code"=>$platform,"is_del"=>0])->find();
  1009. if($ist){
  1010. $god=Db::name("good_basic")->where(["spuCode"=>$value,"is_del"=>0])->find();
  1011. if($god){
  1012. $tp=[];
  1013. $tp['spuCode']=$value;
  1014. $tp['good_name']=$god['good_name'];
  1015. $tp['good_img']=$god['good_thumb_img'];
  1016. $tp['exam_status']=$ist['exam_status'];
  1017. $spec = Db::name("good_spec")->where(["spuCode"=>$value,"is_del"=>0])->select()->toArray();
  1018. $speclist=[];
  1019. if(!empty($spec)){
  1020. foreach ($spec as $val){
  1021. $temp=[];
  1022. $temp['id']=$val['id'];
  1023. $temp['spuCode']=$val['spuCode'];
  1024. $temp['spec_id']=$val['spec_id'];
  1025. $temp['spec_value_id']=$val['spec_value_id'];
  1026. $temp['is_del']=$val['is_del'];
  1027. $sp = Db::name("specs")->where(["id"=>$val['spec_id']])->find();
  1028. $temp['spec_name']=isset($sp["spec_name"]) ? $sp["spec_name"]:"";
  1029. $spv = Db::name("spec_value")->where(["id"=>$val['spec_value_id']])->find();
  1030. $temp['spec_value']=isset($spv["spec_value"]) ? $spv["spec_value"]:"";
  1031. $speclist[]=$temp;
  1032. }
  1033. }
  1034. $tp["speclist"]=empty($speclist)?[]:$speclist;
  1035. $isonline[]=$tp;
  1036. }
  1037. }
  1038. //改变编码规则,将原来的skuCode后两位换成序列号
  1039. //str_pad字符串填充
  1040. $skuCode = makeNo("SN");
  1041. $skuCode = substr($skuCode, 0, -2) . str_pad($i, 2, '0', STR_PAD_LEFT);
  1042. $data[]=[
  1043. "spuCode"=>$value,
  1044. "skuCode"=>$skuCode,
  1045. "platform_code"=>$platform,
  1046. "online_reason"=>$online_reason,
  1047. "online_remark"=>$online_remark,
  1048. "exam_status"=>$count>0 ?2:1,
  1049. "is_online"=>0,
  1050. "status"=>1,
  1051. "is_del"=>0,
  1052. "creater"=>$creater,
  1053. "createrid"=>$createrid,
  1054. "addtime"=>date("Y-m-d H:i:s"),
  1055. "updatetime"=>date("Y-m-d H:i:s")
  1056. ];
  1057. $i++;
  1058. }
  1059. if(!empty($isonline)){
  1060. return app_show(1009,"存在已上线产品",$isonline);
  1061. }
  1062. Db::startTrans();
  1063. $create =Db::name("good_platform")->insertAll($data);
  1064. if($create){
  1065. foreach ($datas as $value){
  1066. $iso = Db::name("good")->where(["spuCode"=>$value['spuCode'],"is_del"=>0])->find();
  1067. if($iso==false){
  1068. unset($value['id']);
  1069. $value['creater']=$creater;
  1070. $value['createrid']=$createrid;
  1071. $value['addtime']=date("Y-m-d H:i:s");
  1072. $value['updatetime']=date("Y-m-d H:i:s");
  1073. }else{
  1074. $value['id']=$iso['id'];
  1075. $value['creater']=$creater;
  1076. $value['createrid']=$createrid;
  1077. $value['updatetime']=date("Y-m-d H:i:s");
  1078. }
  1079. $up =Db::name("good")->save($value);
  1080. if(!$up){
  1081. Db::rollback();
  1082. return error_show(1004,"提交失败");
  1083. }
  1084. //添加审核记录
  1085. //修改状态,添加待办
  1086. $skuCodes = array_column($data, 'skuCode', 'spuCode');
  1087. ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
  1088. "order_code" => $skuCodes[$value['spuCode']],//编号
  1089. "status" => 2,//待产品审核
  1090. "action_remark" => '',//备注
  1091. "action_type" => "create"//新建create,编辑edit,更改状态status
  1092. ], "SPSX", $value['status'], $value);
  1093. ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
  1094. "order_type" => 'SPSX',
  1095. "order_code" => $skuCodes[$value['spuCode']],//咨询单详情编号
  1096. "order_id" => isset($value['id']) ? $value['id'] : 0,
  1097. "order_status" => 2,//待产品审核
  1098. ]);
  1099. }
  1100. Db::commit();
  1101. return app_show(0,"提交成功");
  1102. }else{
  1103. Db::rollback();
  1104. return error_show(1004,"提交失败");
  1105. }
  1106. }
  1107. //审核
  1108. public function online_exam(){
  1109. $skuCode = isset($this->post['skuCode'])&&$this->post['skuCode']!==""?trim($this->post['skuCode']):"";
  1110. if($skuCode===""){
  1111. return error_show(1004,"参数skuCode不能为空");
  1112. }
  1113. $platform = Db::name("good_platform")->where(["skuCode"=>$skuCode,"is_del"=>0])->find();
  1114. if($platform==false){
  1115. return error_show(1004,"未找到数据");
  1116. }
  1117. $exam_status=isset($this->post['exam_status'])&&$this->post['exam_status']!==""?intval($this->post['exam_status']):"";
  1118. // if($exam_status===""){
  1119. // return error_show(1004,"参数exam_status不能为空");
  1120. // }
  1121. if($exam_status==3){
  1122. $online_time= isset($this->post['online_time'])&&$this->post['online_time']!==""?$this->post['online_time']:"";
  1123. if($online_time===""){
  1124. return error_show(1004,"参数online_time不能为空");
  1125. }
  1126. $platform['online_time']=$online_time;
  1127. }
  1128. if($exam_status==6){
  1129. $good_code= isset($this->post['plat_code'])&&$this->post['plat_code']!==""?trim($this->post['plat_code']):"";
  1130. if($good_code===""){
  1131. return error_show(1004,"参数plat_code不能为空");
  1132. }
  1133. $is_exit = Db::name("good_platform")->where(["plat_code"=>$good_code,"is_del"=>0])->find();
  1134. if(($is_exit!=false && $is_exit['id'] !=$platform['id'])|| $is_exit==false){
  1135. $platform['plat_code']=$good_code;
  1136. }else{
  1137. return error_show(1004,"平台订单号 {$good_code} 已存在");
  1138. }
  1139. }
  1140. $exam_remark = isset($this->post['exam_remark'])&&$this->post['exam_remark']!==""?trim($this->post['exam_remark']):"";
  1141. $platform['exam_status']=$exam_status;
  1142. $platform['updatetime']=date("Y-m-d H:i:s");
  1143. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1144. if($token==''){
  1145. return error_show(105,"参数token不能为空");
  1146. }
  1147. $user =GetUserInfo($token);
  1148. if(empty($user)||$user['code']!=0){
  1149. return error_show(1002,"用户数据不存在");
  1150. }
  1151. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1152. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1153. Db::startTrans();
  1154. try {
  1155. $up = Db::name("good_platform")->save($platform);
  1156. if($up){
  1157. $data=[
  1158. "code"=>$platform['skuCode'],
  1159. "exam_status"=>$exam_status,
  1160. "type"=>2,
  1161. "exam_id"=>$createrid,
  1162. "exam_name"=>$creater,
  1163. "exam_remark"=>$exam_remark,
  1164. "addtime"=>date("Y-m-d H:i:s")
  1165. ];
  1166. $inr=Db::name("good_exam")->insert($data);
  1167. if($inr){
  1168. ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
  1169. "order_code" => $skuCode,//编号
  1170. "status" => $exam_status,
  1171. "action_remark" => '',//备注
  1172. "action_type" => "status"//新建create,编辑edit,更改状态status
  1173. ], "SPSX", $exam_status, $platform);
  1174. ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
  1175. "order_type" => 'SPSX',
  1176. "order_code" => $skuCode,//咨询单详情编号
  1177. "order_id" => $platform['id'],
  1178. "order_status" => $exam_status,
  1179. ]);
  1180. Db::commit();
  1181. return app_show(0,"审核成功");
  1182. }else{
  1183. Db::rollback();
  1184. return error_show(1004,"审核失败");
  1185. }
  1186. }else{
  1187. Db::rollback();
  1188. return error_show(1004,"审核失败");
  1189. }
  1190. }catch (\Exception $e){
  1191. Db::rollback();
  1192. return error_show(1004,$e->getMessage());
  1193. }
  1194. }
  1195. //财务定价
  1196. public function editladder(){
  1197. $skuCode = isset($this->post['skuCode'])&&$this->post['skuCode']!==""?trim($this->post['skuCode']):"";
  1198. if($skuCode===""){
  1199. return error_show(1004,"参数skuCode不能为空");
  1200. }
  1201. $platform = Db::name("good_platform")->where(["skuCode"=>$skuCode,"is_del"=>0])->find();
  1202. if($platform==false){
  1203. return error_show(1004,"未找到数据");
  1204. }
  1205. $good_ladder = isset($this->post['good_ladder'])&&!empty($this->post['good_ladder'])?$this->post['good_ladder']:"";
  1206. if($good_ladder==""){
  1207. return error_show(1004,"参数good_ladder不能为空");
  1208. }
  1209. $proof_type = isset($this->post['proof_type'])&&$this->post['proof_type']!==""?intval($this->post['proof_type']):"";
  1210. if($proof_type===""){
  1211. return error_show(1004,"参数proof_type不能为空");
  1212. }
  1213. $proof_url = isset($this->post['proof_url'])&&$this->post['proof_url']!==""?trim($this->post['proof_url']):"";
  1214. if($proof_url===""){
  1215. return error_show(1004,"参数proof_url不能为空");
  1216. }
  1217. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1218. if($token==''){
  1219. return error_show(105,"参数token不能为空");
  1220. }
  1221. $user =GetUserInfo($token);
  1222. if(empty($user)||$user['code']!=0){
  1223. return error_show(1002,"用户数据不存在");
  1224. }
  1225. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1226. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1227. $platform['exam_status']=4;
  1228. $platform['updatetime']=date("Y-m-d H:i:s");
  1229. Db::startTrans();
  1230. try {
  1231. foreach ($good_ladder as $value){
  1232. $lemp=[];
  1233. isset($value["id"])&&$value["id"]!=""?$lemp['id']=$value['id']:"";
  1234. $lemp['skuCode']=$skuCode;
  1235. $lemp['min_num'] = $value['min_num'];
  1236. $lemp['max_num'] = 0;
  1237. $lemp['sale_price'] = $value['sale_price'];
  1238. $lemp['market_price'] = $value['market_price'];
  1239. $lemp['market_platform'] = $value['market_platform'];
  1240. $lemp['cost_fee'] = $value['cost_fee'];
  1241. $lemp['status'] = $value['status'];
  1242. $lemp['is_del'] = isset($value['is_del'])?$value['is_del']:0;
  1243. isset($value["id"])&&$value["id"]!=""?"": $lemp['addtime'] = date("Y-m-d H:i:s");
  1244. $lemp['updatetime'] =date("Y-m-d H:i:s");
  1245. $count = Db::name("good_ladder")->save($lemp);
  1246. if($count==false){
  1247. Db::rollback();
  1248. return app_show(1004,"商品起订价修改失败");
  1249. }
  1250. }
  1251. $up = Db::name("good_platform")->save($platform);
  1252. if($up){
  1253. $proof=[
  1254. 'spuCode'=>$platform['spuCode'],
  1255. 'proof_type'=>$proof_type,
  1256. 'proof_url'=>$proof_url,
  1257. 'is_del'=>0,
  1258. "creater"=>$creater,
  1259. "createrid"=>$createrid,
  1260. "addtime"=>date("Y-m-d H:i:s"),
  1261. "updatetime"=>date("Y-m-d H:i:s")
  1262. ];
  1263. $inproof = Db::name("good_proof")->insert($proof);
  1264. if($inproof==false){
  1265. Db::rollback();
  1266. return app_show(1004,"商品凭证新建失败");
  1267. }
  1268. $data=[
  1269. "code"=>$platform['skuCode'],
  1270. "type"=>2,
  1271. "exam_status"=>4,
  1272. "exam_id"=>$createrid,
  1273. "exam_name"=>$creater,
  1274. "exam_remark"=>'',
  1275. "addtime"=>date("Y-m-d H:i:s")
  1276. ];
  1277. $inr=Db::name("good_exam")->insert($data);
  1278. if($inr){
  1279. //修改状态,添加待办
  1280. ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
  1281. "order_code" => $skuCode,
  1282. "status" => 4,//待财务审核定价
  1283. "action_remark" => '',//备注
  1284. "action_type" => "status"//新建create,编辑edit,更改状态status
  1285. ], "SPSX", 4, $value);
  1286. ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
  1287. "order_type" => 'SPSX',
  1288. "order_code" => $skuCode,
  1289. "order_id" => $platform['id'],
  1290. "order_status" => 4,//待财务审核定价
  1291. ]);
  1292. Db::commit();
  1293. return app_show(0,"审核成功");
  1294. }else{
  1295. Db::rollback();
  1296. return error_show(1004,"审核失败");
  1297. }
  1298. }else{
  1299. Db::rollback();
  1300. return error_show(1004,"审核失败");
  1301. }
  1302. }catch (\Exception $e){
  1303. Db::rollback();
  1304. return error_show(1004,$e->getMessage());
  1305. }
  1306. }
  1307. public function prooflist(){
  1308. $page = isset($this->post['page']) && $this->post['page'] !==""? intval($this->post['page']):"1";
  1309. $size = isset($this->post['size']) && $this->post['size'] !==""? intval($this->post['size']):"10";
  1310. $where =[["is_del","=",0]];
  1311. $spuCode = isset($this->post['spuCode'])&&$this->post['spuCode']!="" ? trim($this->post['spuCode']):"";
  1312. if($spuCode!==""){
  1313. $where[]=["spuCode","like","%$spuCode%"];
  1314. }
  1315. $count = Db::name("good_proof")->where($where)->count();
  1316. $total = ceil($count / $size);
  1317. $page = $page >= $total ? $total : $page;
  1318. $data = Db::name("good_proof")->where($where)->page($page,$size)->order("addtime desc")->select();
  1319. return app_show(0,"获取成功",['list'=>$data,"count"=>$count]);
  1320. }
  1321. /**
  1322. *
  1323. */
  1324. public function againOnline(){
  1325. $skuCode = isset($this->post['skuCode'])&&$this->post['skuCode']!==""?trim($this->post['skuCode']):"";
  1326. if($skuCode===""){
  1327. return error_show(1004,"参数skuCode不能为空");
  1328. }
  1329. $platform = Db::name("good_platform")->where(["skuCode"=>$skuCode,"is_del"=>0])->find();
  1330. if($platform==false){
  1331. return error_show(1004,"未找到数据");
  1332. }
  1333. if($platform["exam_status"]!=7&&$platform["exam_status"]!=8){
  1334. return error_show(1004,"商品状态有误");
  1335. }
  1336. $nake =Db::name("good_nake")->where(["spuCode"=>$platform['spuCode'],"is_del"=>0])->select()->toArray();
  1337. $platform['exam_status'] = empty($nake)?1:2;
  1338. $platform['updatetime'] = date("Y-m-d H:i:s");
  1339. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1340. if($token==''){
  1341. return error_show(105,"参数token不能为空");
  1342. }
  1343. $user =GetUserInfo($token);
  1344. if(empty($user)||$user['code']!=0){
  1345. return error_show(1002,"用户数据不存在");
  1346. }
  1347. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1348. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1349. Db::startTrans();
  1350. try {
  1351. $save =Db::name("good_platform")->save($platform);
  1352. if($save){
  1353. $data=[
  1354. "code"=>$platform['skuCode'],
  1355. "type"=>2,
  1356. "exam_status"=>$platform['exam_status'] ,
  1357. "exam_id"=>$createrid,
  1358. "exam_name"=>$creater,
  1359. "exam_remark"=>'',
  1360. "addtime"=>date("Y-m-d H:i:s")
  1361. ];
  1362. $inr=Db::name("good_exam")->insert($data);
  1363. if($inr){
  1364. Db::commit();
  1365. return app_show(0,"审核成功");
  1366. }
  1367. }
  1368. Db::rollback();
  1369. return error_show(1004,"审核失败");
  1370. }catch (\Exception $e){
  1371. Db::rollback();
  1372. return error_show(1004,$e->getMessage());
  1373. }
  1374. }
  1375. public function copy(){
  1376. $supcode = isset($this->post['spuCode'])&&$this->post['spuCode']!="" ? trim($this->post['spuCode']):"";
  1377. if($supcode==""){
  1378. return error_show(1004,"参数spuCode不能为空");
  1379. }
  1380. $data = Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->find();
  1381. if($data==false){
  1382. return error_show(1004,"未找到商品数据");
  1383. }
  1384. $token = isset($this->post['token'])&& $this->post['token']!='' ? trim($this->post['token']):"";
  1385. if($token==''){
  1386. return error_show(105,"参数token不能为空");
  1387. }
  1388. $user =GetUserInfo($token);
  1389. if(empty($user)||$user['code']!=0){
  1390. return error_show(102,"用户数据不存在");
  1391. }
  1392. $createrid= isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1393. $creater= isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1394. $nake = Db::name("good_nake")->where(["spuCode"=>$supcode,"is_del"=>0])->select()->toArray();
  1395. $ladd=[];
  1396. $newCode =makeNo("SKU");
  1397. if(!empty($nake)){
  1398. foreach ($nake as $value){
  1399. $tmp=[];
  1400. $tmp['spuCode']=$newCode;
  1401. $tmp['min_num']=$value['min_num'];
  1402. $tmp['nake_fee'] = $value['nake_fee'];
  1403. $tmp['cost_fee'] = $value['cost_fee'];
  1404. $tmp['delivery_fee'] = $value['delivery_fee'];
  1405. $tmp['cert_fee'] = $value['cert_fee'];
  1406. $tmp['mark_fee'] = $value['mark_fee'];
  1407. $tmp['package_fee'] = $value['package_fee'];
  1408. $tmp['other_fee'] = $value['other_fee'];
  1409. $tmp['nake_total'] =$value['nake_total'];
  1410. $tmp['creater_id']=$createrid;
  1411. $tmp['creater']=$creater;
  1412. $tmp['is_del']=$value['is_del'];
  1413. $tmp['addtime']=date("Y-m-d H:i:s");
  1414. $tmp['updatetime']=date("Y-m-d H:i:s");
  1415. $ladd[]=$tmp;
  1416. }
  1417. }
  1418. $spec = Db::name("good_spec")->where(["spuCode"=>$supcode,"is_del"=>0])->select()->toArray();
  1419. $specArr=[];
  1420. if(!empty($spec)){
  1421. foreach ($spec as $value){
  1422. $tmp=[];
  1423. $tmp['spuCode']=$newCode;
  1424. $tmp['spec_id']=$value['spec_id'];
  1425. $tmp['spec_value_id']=$value['spec_value_id'];
  1426. $tmp['is_del']=$value['is_del'];
  1427. $tmp['addtime']=date("Y-m-d H:i:s");
  1428. $tmp['updatetime']=date("Y-m-d H:i:s");
  1429. $specArr[]=$tmp;
  1430. }
  1431. }
  1432. Db::startTrans();
  1433. try {
  1434. unset($data['id']);
  1435. $data['spuCode']=$newCode;
  1436. $data['createrid']=$createrid;
  1437. $data['creater']=$creater;
  1438. $data['status']=7;
  1439. $data['addtime']=date("Y-m-d H:i:s");
  1440. $data['updatetime']=date("Y-m-d H:i:s");
  1441. $cre = Db::name("good_basic")->insert($data);
  1442. if($cre){
  1443. if(!empty($ladd)){
  1444. $na = Db::name("good_nake")->insertAll($ladd);
  1445. if($na==0){
  1446. Db::rollback();
  1447. return error_show(1005,"成本数据复制失败");
  1448. }
  1449. }
  1450. if(!empty($specArr)){
  1451. $sp = Db::name("good_spec")->insertAll($specArr);
  1452. if($sp==0){
  1453. Db::rollback();
  1454. return error_show(1005,"规格数据复制失败");
  1455. }
  1456. }
  1457. Db::commit();
  1458. return app_show(0,"复制数据成功",["spuCode"=>$newCode]);
  1459. }else{
  1460. Db::rollback();
  1461. return error_show(1005,"数据复制失败");
  1462. }
  1463. }catch (\Exception $e){
  1464. Db::rollback();
  1465. return error_show(1004,$e->getMessage());
  1466. }
  1467. }
  1468. public function edit(){
  1469. $supcode = isset($this->post['spuCode'])&&$this->post['spuCode']!="" ? trim($this->post['spuCode']):"";
  1470. if($supcode==""){
  1471. return error_show(1004,"参数spuCode不能为空");
  1472. }
  1473. $data = Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->find();
  1474. if($data==false){
  1475. return error_show(1004,"未找到商品数据");
  1476. }
  1477. if ($data['status'] != 6 && $data['status'] != 7 && $data['status'] != 8) {
  1478. return error_show(1004,"商品状态有误");
  1479. }
  1480. $good_name= isset($this->post['good_name'])&&$this->post['good_name']!="" ? trim($this->post['good_name']):"";
  1481. if($good_name==""){
  1482. return error_show(1004,"商品名称不能为空");
  1483. }
  1484. $cat_id = isset($this->post['cat_id'])&&$this->post['cat_id']!=""? intval($this->post['cat_id']):"";
  1485. if($cat_id==''){
  1486. return error_show(1004,"商品分类不能为空");
  1487. }
  1488. $brandid = isset($this->post['brandid'])&&$this->post['brandid']!=""? intval($this->post['brandid']):"0";
  1489. // if($brandid==''){
  1490. // return error_show(1004,"商品品牌不能为空");
  1491. // }
  1492. $unit = isset($this->post['unit'])&&$this->post['unit']!=""? trim($this->post['unit']):"";
  1493. if($unit==''){
  1494. return error_show(1004,"商品单位不能为空");
  1495. }
  1496. $good_type = isset($this->post['good_type'])&&$this->post['good_type']!==""? intval($this->post['good_type'])
  1497. :"";
  1498. if($good_type===''){
  1499. return error_show(1004,"参数good_type不能为空");
  1500. }
  1501. $moq=0;
  1502. $customized=0;
  1503. if($good_type==1){
  1504. $moq = isset($this->post['moq'])&&$this->post['moq']!==""? intval($this->post['moq']):"";
  1505. if($moq===''){
  1506. return error_show(1004,"定制商品起订量不能为空");
  1507. }
  1508. $customized = isset($this->post['customized'])&&$this->post['customized']!==""? intval($this->post['customized']):"";
  1509. if($customized===''){
  1510. return error_show(1004,"参数customized不能为空");
  1511. }
  1512. }
  1513. $is_exclusive = isset($this->post['is_exclusive'])&&$this->post['is_exclusive']!==""? intval($this->post['is_exclusive']):"";
  1514. if($is_exclusive===''){
  1515. return error_show(1004,"参数is_exclusive不能为空");
  1516. }
  1517. // $customized = isset($this->post['customized'])&&$this->post['customized']!==""? intval($this->post['customized']):"";
  1518. // if($customized===''){
  1519. // return error_show(1004,"参数customized不能为空");
  1520. // }
  1521. $tax = isset($this->post['tax'])&&$this->post['tax']!==""? intval($this->post['tax']):"";
  1522. if($tax===''){
  1523. return error_show(1004,"参数tax不能为空");
  1524. }
  1525. $supplierNo = isset($this->post['supplierNo'])&&$this->post['supplierNo']!=""? trim($this->post['supplierNo']):"";
  1526. if($supplierNo==''){
  1527. return error_show(1004,"参数supplierNo不能为空");
  1528. }
  1529. $good_size = isset($this->post['good_size'])&&$this->post['good_size']!=""? trim($this->post['good_size'])
  1530. :"";
  1531. if($good_size==''){
  1532. return error_show(1004,"参数good_size不能为空");
  1533. }
  1534. $company_id = isset($this->post['companyNo'])&&$this->post['companyNo']!=""? trim($this->post['companyNo'])
  1535. :"";
  1536. if($company_id==''){
  1537. return error_show(1004,"参数companyNo不能为空");
  1538. }
  1539. $is_auth = isset($this->post['is_auth'])&&$this->post['is_auth']!==""? intval($this->post['is_auth']):"";
  1540. if($is_auth===''){
  1541. return error_show(1004,"参数is_auth不能为空");
  1542. }
  1543. $auth_img = isset($this->post['auth_img'])&&$this->post['auth_img']!=""? trim($this->post['auth_img']):"";
  1544. // if($auth_img==''){
  1545. // return error_show(1004,"商品不能为空");
  1546. // }
  1547. $after_sales = isset($this->post['after_sales'])&&$this->post['after_sales']!=""? trim($this->post['after_sales']):"";
  1548. if($after_sales==""){
  1549. return error_show(1004,"参数after_sales不能为空");
  1550. }
  1551. $craft_desc = isset($this->post['craft_desc'])&&$this->post['craft_desc']!=""? trim($this->post['craft_desc']):"";
  1552. $good_remark = isset($this->post['good_remark'])&&$this->post['good_remark']!=""? trim($this->post['good_remark']):"";
  1553. if($good_remark===""){
  1554. return error_show(1004,"参数good_remark不能为空");
  1555. }
  1556. $weight = isset($this->post['weight'])&&$this->post['weight']!==""? floatval($this->post['weight']):"";
  1557. if($weight===""){
  1558. return error_show(1004,"参数weight不能为空");
  1559. }
  1560. $packing_way = isset($this->post['packing_way'])&&$this->post['packing_way']!==""? trim($this->post['packing_way']):"";
  1561. if($packing_way===""){
  1562. return error_show(1004,"参数packing_way不能为空");
  1563. }
  1564. $packing_size = isset($this->post['packing_size'])&&$this->post['packing_size']!==""? trim($this->post['packing_size']):"";
  1565. if($packing_size===""){
  1566. return error_show(1004,"参数packing_size不能为空");
  1567. }
  1568. $packing_spec = isset($this->post['packing_spec'])&&$this->post['packing_spec']!==""? trim($this->post['packing_spec']):"";
  1569. if($packing_spec===""){
  1570. return error_show(1004,"参数packing_spec不能为空");
  1571. }
  1572. $packing_weight = isset($this->post['packing_weight'])&&$this->post['packing_weight']!==""? floatval($this->post['packing_weight']):"";
  1573. if($packing_weight===""){
  1574. return error_show(1004,"参数packing_weight不能为空");
  1575. }
  1576. $packing_list = isset($this->post['packing_list'])&&$this->post['packing_list']!==""? trim($this->post['packing_list']):"";
  1577. if($packing_list===""){
  1578. return error_show(1004,"参数packing_list不能为空");
  1579. }
  1580. $good_bar = isset($this->post['good_bar'])&&$this->post['good_bar']!==""? trim($this->post['good_bar']):"";
  1581. $supply_area = isset($this->post['supply_area'])&&$this->post['supply_area']!==""? intval($this->post['supply_area']):"";
  1582. if($supply_area===""){
  1583. return error_show(1004,"参数supply_area不能为空");
  1584. }
  1585. $delivery_place = isset($this->post['delivery_place'])&&$this->post['delivery_place']!==""? $this->post['delivery_place']:"";
  1586. if($delivery_place===""){
  1587. return error_show(1004,"参数delivery_place不能为空");
  1588. }
  1589. $origin_place = isset($this->post['origin_place'])&&$this->post['origin_place']!==""? $this->post['origin_place']:"";
  1590. if($origin_place===""){
  1591. return error_show(1004,"参数origin_place不能为空");
  1592. }
  1593. $delivery_day = isset($this->post['delivery_day'])&&$this->post['delivery_day']!==""? intval($this->post['delivery_day']):"";
  1594. if($delivery_day===""){
  1595. return error_show(1004,"参数delivery_day不能为空");
  1596. }
  1597. $lead_time = isset($this->post['lead_time'])&&$this->post['lead_time']!==""? intval($this->post['lead_time'])
  1598. :"0";
  1599. // if($lead_time===""){
  1600. // return error_show(1004,"参数lead_time不能为空");
  1601. // }
  1602. $sample_day = isset($this->post['sample_day'])&&$this->post['sample_day']!==""? intval($this->post['sample_day']):"0";
  1603. // if($sample_day===""){
  1604. // return error_show(1004,"参数sample_day不能为空");
  1605. // }
  1606. $sample_fee = isset($this->post['sample_fee'])&&$this->post['sample_fee']!==""? floatval($this->post['sample_fee']):"0";
  1607. $good_img = isset($this->post['good_img'])&&$this->post['good_img']!=""? trim($this->post['good_img']):"";
  1608. if($good_img===""){
  1609. return error_show(1004,"参数good_img不能为空");
  1610. }
  1611. $good_thumb_img = isset($this->post['good_thumb_img'])&&$this->post['good_thumb_img']!==""? trim($this->post['good_thumb_img']):"";
  1612. if($good_thumb_img===""){
  1613. return error_show(1004,"参数good_thumb_img不能为空");
  1614. }
  1615. $good_info_img = isset($this->post['good_info_img'])&&!empty($this->post['good_info_img'])? trim($this->post['good_info_img']):"";
  1616. if($good_info_img===""){
  1617. return error_show(1004,"参数good_info_img不能为空");
  1618. }
  1619. $cert_fee = isset($this->post['cert_fee'])&&$this->post['cert_fee']!==""? floatval($this->post['cert_fee']):"0";
  1620. $packing_fee = isset($this->post['packing_fee'])&&$this->post['packing_fee']!==""? floatval($this->post['packing_fee']):"0";
  1621. $cost_fee = isset($this->post['cost_fee'])&&$this->post['cost_fee']!==""? floatval($this->post['cost_fee']):"0";
  1622. $mark_fee = isset($this->post['mark_fee'])&&$this->post['mark_fee']!==""? floatval($this->post['mark_fee']):"0";
  1623. $demo_fee = isset($this->post['demo_fee'])&&$this->post['demo_fee']!==""? floatval($this->post['demo_fee']):"0";
  1624. $open_fee = isset($this->post['open_fee'])&&$this->post['open_fee']!==""? floatval($this->post['open_fee']):"0";
  1625. $noble_metal = isset($this->post['noble_metal'])&&$this->post['noble_metal']!==""? intval($this->post['noble_metal']):"0";
  1626. $noble_weight = isset($this->post['noble_weight'])&&$this->post['noble_weight']!==""? floatval($this->post['noble_weight']):"0";
  1627. $is_gold_price= isset($this->post['is_gold_price'])&&$this->post['is_gold_price']!==""? intval($this->post['is_gold_price']):"0";
  1628. $market_price = isset($this->post['market_price'])&&$this->post['market_price']!==""? floatval($this->post['market_price']):"";
  1629. $cgd_gold_price = isset($this->post['cgd_gold_price'])&&$this->post['cgd_gold_price']!==""? floatval($this->post['cgd_gold_price']):"0";
  1630. if($market_price===""){
  1631. return error_show(1004,"参数market_price不能为空");
  1632. }
  1633. $nake_price = isset($this->post['nake_price'])&&$this->post['nake_price']!==""? floatval($this->post['nake_price']):"0";
  1634. $config = isset($this->post['config'])&&$this->post['config']!==""? trim($this->post['config']):"";
  1635. $other_config = isset($this->post['other_config'])&&$this->post['other_config']!==""? trim($this->post['other_config']):"";
  1636. $is_diff = isset($this->post['is_diff'])&&$this->post['is_diff']!==""? intval($this->post['is_diff']):"0";
  1637. $is_stock = isset($this->post['is_stock'])&&$this->post['is_stock']!==""? intval($this->post['is_stock']):"0";
  1638. // $is_step = isset($this->post['is_step'])&&$this->post['is_step']!==""? intval($this->post['is_step']):"";
  1639. // if($is_step===""){
  1640. // return error_show(1004,"参数is_step不能为空");
  1641. // }
  1642. $good_ladder = isset($this->post['good_ladder'])&&!empty($this->post['good_ladder'])? $this->post['good_ladder']:"";
  1643. // if($is_step==1 && $good_ladder==""){
  1644. // return error_show(1004,"启用阶梯,阶梯价不能为空");
  1645. // }
  1646. $speclist = isset($this->post['speclist'])&&!empty($this->post['speclist'])? $this->post['speclist']:"";
  1647. Db::startTrans();
  1648. try {
  1649. $temp=[
  1650. "good_name"=>$good_name,
  1651. "cat_id"=>$cat_id,
  1652. 'brand_id'=>$brandid,
  1653. "good_unit"=>$unit,
  1654. "good_type"=>$good_type,
  1655. "companyNo"=>$company_id,
  1656. "moq"=>$moq,
  1657. "is_exclusive"=>$is_exclusive,
  1658. "customized"=>$customized,
  1659. "tax"=>$tax,
  1660. "supplierNo"=>$supplierNo,
  1661. "is_auth"=>$is_auth,
  1662. "good_size"=>$good_size,
  1663. "auth_img"=>$auth_img,
  1664. "after_sales"=>$after_sales,
  1665. "craft_desc"=>$craft_desc,
  1666. "good_remark"=>$good_remark,
  1667. "weight"=>$weight,
  1668. "packing_way"=>$packing_way,
  1669. "packing_size"=>$packing_size,
  1670. "packing_spec"=>$packing_spec,
  1671. "packing_list"=>$packing_list,
  1672. "packing_weight"=>$packing_weight,
  1673. "good_bar"=>$good_bar,
  1674. "supply_area"=>$supply_area,
  1675. "delivery_place"=>$delivery_place,
  1676. "origin_place"=>$origin_place,
  1677. "delivery_day"=>$delivery_day,
  1678. "lead_time"=>$lead_time,
  1679. "sample_day"=>$sample_day,
  1680. "sample_fee"=>$sample_fee,
  1681. "good_img"=>$good_img,
  1682. "good_thumb_img"=>$good_thumb_img,
  1683. "good_info_img"=>$good_info_img,
  1684. "cert_fee"=>$cert_fee,
  1685. "packing_fee"=>$packing_fee,
  1686. "is_diff"=>$is_diff,
  1687. "config"=>$config,
  1688. "other_config"=>$other_config,
  1689. "is_stock"=>$is_stock,
  1690. "cost_fee"=>$cost_fee,
  1691. "mark_fee"=>$mark_fee,
  1692. "demo_fee"=>$demo_fee,
  1693. "open_fee"=>$open_fee,
  1694. "noble_metal"=>$noble_metal,
  1695. "noble_weight"=>$noble_weight,
  1696. "is_gold_price"=>$is_gold_price,
  1697. "market_price"=>$market_price,
  1698. "nake_price"=>$nake_price,
  1699. "cgd_gold_price"=>$cgd_gold_price,
  1700. "is_step" => count($good_ladder) > 1 ? 1 : 0,
  1701. "status"=>"0",
  1702. "updatetime"=>date("Y-m-d H:i:s")
  1703. ];
  1704. $field = array_diff_assoc($temp,$data);
  1705. $temp['field_change'] =empty($field)?"":json_encode(array_keys($field));
  1706. $up = Db::name("good_basic")->where(["spuCode"=>$supcode,"is_del"=>0])->save($temp);
  1707. $var = array_diff($temp,$data);
  1708. $json = json_encode($var,JSON_UNESCAPED_UNICODE);
  1709. $dat = json_encode($data,JSON_UNESCAPED_UNICODE);
  1710. if($up){
  1711. ChangeLog::logAdd(3,$data['spuCode'],$dat,$json,$this->post['token'],$this->post);
  1712. if($speclist!=="" && !empty($speclist)){
  1713. foreach ($speclist as $value){
  1714. $lemp=[];
  1715. isset($value["id"])&&$value["id"]!=''?$lemp['id']=$value['id']:"";
  1716. $lemp['spuCode']=$supcode;
  1717. $lemp['spec_id'] = $value['spec_id'];
  1718. $lemp['spec_value_id'] = $value['spec_value_id'];
  1719. $lemp['is_del'] = isset($value['is_del'])?$value['is_del']:0;
  1720. isset($value["id"])&&$value["id"]!=''?"": $lemp['addtime'] = date("Y-m-d H:i:s");
  1721. $lemp['updatetime'] =date("Y-m-d H:i:s");
  1722. $count = Db::name("good_spec")->save($lemp);
  1723. if($count==false){
  1724. Db::rollback();
  1725. return app_show(1004,"商品规格值修改失败");
  1726. }
  1727. }
  1728. }
  1729. if($good_ladder!=="" && !empty($good_ladder)){
  1730. $user =GetUserInfo($this->post['token']);//获取用户信息,下面更新成本表的创建人
  1731. $top_cat_id = made($cat_id);//获取所有分类
  1732. $top_cat_id = isset($top_cat_id[0]['id']) ? $top_cat_id[0]['id'] : 0;//获取顶级分类id
  1733. foreach ($good_ladder as $value){
  1734. $lemp=[];
  1735. isset($value["id"])&&$value["id"]!=''?$lemp['id']=$value['id']:"";
  1736. $lemp['spuCode']=$supcode;
  1737. $lemp['min_num'] = $value['min_num'];
  1738. $lemp['nake_fee'] = $value['nake_fee'];
  1739. $lemp['cost_fee'] = $value['cost_fee'];
  1740. $lemp['delivery_fee'] = $value['delivery_fee'];
  1741. $lemp['cert_fee'] = $value['cert_fee'];
  1742. $lemp['mark_fee'] = $value['mark_fee'];
  1743. $lemp['package_fee'] = $value['package_fee'];
  1744. $lemp['other_fee'] = $value['other_fee'];
  1745. if ($is_gold_price == 1 && $top_cat_id == 6) {
  1746. $gold =Db::name("gold_price1")->where(["type"=>$noble_metal,"status"=>1,"is_del"=>0])->order("addtime desc")->find();
  1747. //$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'];
  1748. //成本合计=贵金属重量*供应商采购金价 + 工艺费*贵金属重量+加标费+包装费+证书费+成本裸价+运费+其他费用
  1749. //成本总计启用实时金价时,采用供应商实时金价
  1750. $lemp['nake_total'] =$noble_weight *$gold['price']+ $value['cost_fee'] * $noble_weight +
  1751. $value['mark_fee'] + $value['package_fee'] + $value['cert_fee'] + $value['nake_fee'] + $value['delivery_fee'] + $value['other_fee'];
  1752. }else{
  1753. $lemp['nake_total'] =$value['nake_fee']+$value['delivery_fee']+$value['cert_fee']+$value['mark_fee']+$value['package_fee']+$value['other_fee'];
  1754. }
  1755. $lemp['creater_id'] = isset($user["data"]['id']) ? $user["data"]['id'] : 0;
  1756. $lemp['creater'] = isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1757. $lemp['is_del'] = isset($value['is_del'])?$value['is_del']:0;
  1758. isset($value["id"])&&$value["id"]!=''?"": $lemp['addtime'] = date("Y-m-d H:i:s");
  1759. $lemp['updatetime'] =date("Y-m-d H:i:s");
  1760. $count = Db::name("good_nake")->save($lemp);
  1761. if($count==false){
  1762. Db::rollback();
  1763. return app_show(1004,"商品规成本修改失败");
  1764. }
  1765. }
  1766. }
  1767. Db::commit();
  1768. return app_show(0,"更新成功");
  1769. }else{
  1770. Db::rollback();
  1771. return error_show(1005,"更新失败");
  1772. }
  1773. }catch (\Exception $e){
  1774. Db::rollback();
  1775. return error_show(1004,$e->getMessage());
  1776. }
  1777. }
  1778. public function checkPrice(){
  1779. $spuCode=isset($this->post['spuCode'])&&$this->post['spuCode']!=""? trim($this->post['spuCode']):"";
  1780. if($spuCode==""){
  1781. return error_show(1005,"参数spuCode不能为空");
  1782. }
  1783. $good =Db::name("good_basic")->where(["spuCode"=>$spuCode,"is_del"=>0])->find();
  1784. if($good==false){
  1785. return error_show(1005,"商品数据未找到");
  1786. }
  1787. $num=isset($this->post['min_num'])&&$this->post['min_num']!=="" ? intval($this->post['min_num']):"";
  1788. if($num==""){
  1789. return error_show(1005,"参数min_num不能为空");
  1790. }
  1791. $nakelist = Db::name("good_nake")->where(['spuCode'=>$spuCode,"is_del"=>0])->where([["min_num","<=",$num]])
  1792. ->order("min_num desc")->find();
  1793. if($nakelist==false){
  1794. $nakelist = Db::name("good_nake")->where(['spuCode'=>$spuCode,"is_del"=>0])->order("min_num asc")->find();
  1795. return error_show(1010,"起订量不足{$nakelist['min_num']}");
  1796. }
  1797. $catinfo = Db::name("cat")->where(["id"=>$good['cat_id']])->find();
  1798. $budget = isset($catinfo['sale_rate']) ? $catinfo['sale_rate']/100:0;
  1799. $top_cat_id = made($catinfo['id']);//获取所有分类
  1800. $top_cat_id = isset($top_cat_id[0]['id']) ? $top_cat_id[0]['id'] : 0;//获取顶级分类id
  1801. $sale_cost_fee = 0;
  1802. if ($good['is_gold_price'] == 1 && $top_cat_id == 6) {
  1803. // $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'];
  1804. //系统售价=(贵金属重量*供应商采购金价 + 工艺费*贵金属重量+加标费+包装费+证书费+成本裸价+运费+其他费用)/(1-成本售价/100)
  1805. $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);
  1806. //计算工艺费
  1807. //销售工艺费=(( 商品重量* 供应商采购金价 + 采购成本工艺费* 商品重量+包装费+加标费+证书费+产品裸价+其他费用)/(1-成本售价/100)-(包装费+加标费+证书费+产品裸价0+运费+其他费用) )/商品重量-供应商采购金价
  1808. $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"];
  1809. }else{
  1810. $saleprice = ($nakelist['mark_fee'] + $nakelist['package_fee'] + $nakelist['cert_fee'] + $nakelist['delivery_fee'] + $nakelist['nake_fee']) / (1 - $budget);
  1811. }
  1812. return app_show(0, "获取成功", ["sale_price" => round($saleprice, 2), 'new_cost_fee' => round($sale_cost_fee, 2)]);
  1813. }
  1814. //咨询成交商品池 添加上线商品
  1815. public function onlineZixunGoods()
  1816. {
  1817. $param = $this->request->only(['platform', 'codes', 'online_reason', 'online_remark', 'token'], 'post', 'trim');
  1818. $val = Validate::rule([
  1819. 'platform|所选上线平台' => 'require|number|gt:0',
  1820. 'codes|所选上线商品编号' => 'require',
  1821. 'online_reason|上线原因' => 'require',
  1822. 'online_remark|上线备注' => 'require',
  1823. 'token' => 'require',
  1824. ]);
  1825. if (!$val->check($param)) return error_show(1004, $val->getError());
  1826. $good_zixun_list = Db::name("good_zixun")
  1827. ->where(["is_del" => 0])
  1828. ->whereIn('spuCode', $param['codes'])
  1829. ->column('*', 'spuCode');
  1830. if (empty($good_zixun_list)) return error_show(1004, "未找到相关咨询商品数据");
  1831. $a = array_diff($param['codes'], array_keys($good_zixun_list));
  1832. if (!empty($a)) return error_show(1005, '该咨询商品不存在' . implode(',', $a));
  1833. $isonline = Db::name("good_platform")
  1834. ->alias('gp')
  1835. ->field('gp.id,gp.spuCode,gb.good_name,gb.good_img,gp.exam_status')
  1836. ->where(["gp.platform_code" => $param['platform'], "gp.is_del" => 0])
  1837. ->whereIn('gp.spuCode', $param['codes'])
  1838. ->leftJoin('good_basic gb', 'gb.spuCode=gp.spuCode AND gb.is_del=0')
  1839. ->select()
  1840. ->toArray();
  1841. if (!empty($isonline)) {
  1842. foreach ($isonline as &$v) {
  1843. $spec = Db::name("good_spec")
  1844. ->where(["spuCode" => $v['spuCode'], "is_del" => 0])
  1845. ->select()
  1846. ->toArray();
  1847. $speclist = [];
  1848. if (!empty($spec)) {
  1849. foreach ($spec as $val) {
  1850. $temp = [];
  1851. $temp['id'] = $val['id'];
  1852. $temp['spuCode'] = $val['spuCode'];
  1853. $temp['spec_id'] = $val['spec_id'];
  1854. $temp['spec_value_id'] = $val['spec_value_id'];
  1855. $temp['is_del'] = $val['is_del'];
  1856. $sp = Db::name("specs")->where(["id" => $val['spec_id']])->find();
  1857. $temp['spec_name'] = isset($sp["spec_name"]) ? $sp["spec_name"] : "";
  1858. $spv = Db::name("spec_value")->where(["id" => $val['spec_value_id']])->find();
  1859. $temp['spec_value'] = isset($spv["spec_value"]) ? $spv["spec_value"] : "";
  1860. $speclist[] = $temp;
  1861. }
  1862. }
  1863. $v["speclist"] = empty($speclist) ? [] : $speclist;
  1864. }
  1865. return app_show(1009, "存在已上线产品", $isonline);
  1866. }
  1867. if (!empty($isonline)) return error_show(1005, $isonline['spuCode'] . '该商品已在商品成本管理中,请在商品成本管理菜单提交上线!');
  1868. $user = GetUserInfo($param['token']);
  1869. if (empty($user) || $user['code'] != 0) return error_show(1002, "用户数据不存在");
  1870. $createrid = isset($user["data"]['id']) ? $user["data"]['id'] : "";
  1871. $creater = isset($user["data"]['nickname']) ? $user["data"]['nickname'] : "";
  1872. $data = $good_insert_data = $good_basic_insert_data = $good_spec_insert_data = [];
  1873. $i = 0;
  1874. $all_nakes = Db::name("good_nake")
  1875. ->where(["is_del" => 0])->fetchSql()
  1876. ->whereIn('spuCode', $param['codes'])
  1877. ->group('spuCode')
  1878. ->column('count(`id`) total', 'spuCode');
  1879. $all_good = Db::name('good')
  1880. ->where('is_del', 0)
  1881. ->whereIn('spuCode', $param['codes'])
  1882. ->column('id', 'spuCode');
  1883. if (!empty($all_good)) return error_show(1004, '请从商品成本提交该商品上线');
  1884. $all_good_basic = Db::name('good_basic')
  1885. ->where('is_del', 0)
  1886. ->whereIn('spuCode', $param['codes'])
  1887. ->column('id', 'spuCode');
  1888. if (!empty($all_good_basic)) return error_show(1004, '请从商品成本提交该商品上线');
  1889. foreach ($param['codes'] as $value) {
  1890. //改变编码规则,将原来的skuCode后两位换成序列号
  1891. //str_pad字符串填充
  1892. $skuCode = makeNo("SN");
  1893. $skuCode = substr($skuCode, 0, -2) . str_pad($i, 2, '0', STR_PAD_LEFT);
  1894. $data[] = [
  1895. "spuCode" => $value,
  1896. "skuCode" => $skuCode,
  1897. "platform_code" => $param['platform'],
  1898. "online_reason" => $param['online_reason'],
  1899. "online_remark" => $param['online_remark'],
  1900. "exam_status" => isset($all_nakes[$value]) ? ($all_nakes[$value] > 0 ? 2 : 1) : 1,
  1901. "is_online" => 0,
  1902. "status" => 0,
  1903. "is_del" => 0,
  1904. "creater" => $creater,
  1905. "createrid" => $createrid,
  1906. "addtime" => date("Y-m-d H:i:s"),
  1907. "updatetime" => date("Y-m-d H:i:s")
  1908. ];
  1909. //good表
  1910. if (!isset($all_good[$value])) {
  1911. $good_insert_data[] = [
  1912. 'spuCode' => $good_zixun_list[$value]['spuCode'],
  1913. 'good_code' => $good_zixun_list[$value]['good_code'],
  1914. 'good_name' => $good_zixun_list[$value]['good_name'],
  1915. 'cat_id' => $good_zixun_list[$value]['cat_id'],
  1916. 'brand_id' => $good_zixun_list[$value]['brand_id'],
  1917. 'good_unit' => $good_zixun_list[$value]['good_unit'],
  1918. 'good_type' => $good_zixun_list[$value]['good_type'],
  1919. 'companyNo' => $good_zixun_list[$value]['companyNo'],
  1920. 'moq' => $good_zixun_list[$value]['moq'],
  1921. 'customized' => $good_zixun_list[$value]['customized'],
  1922. 'tax' => $good_zixun_list[$value]['tax'],
  1923. 'supplierNo' => $good_zixun_list[$value]['supplierNo'],
  1924. 'is_auth' => $good_zixun_list[$value]['is_auth'],
  1925. 'is_stock' => '',
  1926. 'auth_img' => $good_zixun_list[$value]['auth_img'],
  1927. 'after_sales' => '',
  1928. 'craft_desc' => $good_zixun_list[$value]['craft_desc'],
  1929. 'good_remark' => $good_zixun_list[$value]['good_remark'],
  1930. 'good_size' => '',
  1931. 'weight' => $good_zixun_list[$value]['weight'],
  1932. 'packing_way' => '',
  1933. 'packing_size' => '',
  1934. 'packing_spec' => '',
  1935. 'packing_list' => '',
  1936. 'packing_weight' => '',
  1937. 'good_bar' => '',
  1938. 'supply_area' => $good_zixun_list[$value]['supply_area'],
  1939. 'delivery_place' => '',
  1940. 'origin_place' => '',
  1941. 'delivery_day' => 0,
  1942. 'lead_time' => '',
  1943. 'sample_day' => '',
  1944. 'sample_fee' => '',
  1945. 'good_img' => $good_zixun_list[$value]['good_img'],
  1946. 'good_thumb_img' => $good_zixun_list[$value]['good_thumb_img'],
  1947. 'good_info_img' => $good_zixun_list[$value]['good_info_img'],
  1948. 'cert_fee' => '',
  1949. 'packing_fee' => '',
  1950. 'cost_fee' => '',
  1951. 'mark_fee' => '',
  1952. 'demo_fee' => '',
  1953. 'open_fee' => '',
  1954. 'noble_metal' => $good_zixun_list[$value]['noble_metal'],
  1955. 'noble_weight' => $good_zixun_list[$value]['good_weight'],
  1956. 'is_gold_price' => $good_zixun_list[$value]['is_gold_price'],
  1957. 'cgd_gold_price' => '',
  1958. 'market_price' => '',
  1959. 'nake_price' => '',
  1960. 'is_step' => '',
  1961. 'is_online' => '',
  1962. 'status' => 1,//待完善成本
  1963. 'createrid' => $createrid,
  1964. 'creater' => $creater,
  1965. 'is_del' => 0,
  1966. 'field_change' => '',
  1967. 'addtime' => date('Y-m-d H:i:s'),
  1968. 'updatetime' => date('Y-m-d H:i:s'),
  1969. 'is_exclusive' => '',
  1970. 'is_diff' => $good_zixun_list[$value]['is_diff'],
  1971. 'config' => $good_zixun_list[$value]['config'],
  1972. 'other_config' => $good_zixun_list[$value]['other_config'],
  1973. ];
  1974. }
  1975. //good_basic表
  1976. if (!isset($all_good_basic[$value])) {
  1977. $good_basic_insert_data[] = [
  1978. 'spuCode' => $good_zixun_list[$value]['spuCode'],
  1979. 'good_code' => $good_zixun_list[$value]['good_code'],
  1980. 'good_name' => $good_zixun_list[$value]['good_name'],
  1981. 'cat_id' => $good_zixun_list[$value]['cat_id'],
  1982. 'brand_id' => $good_zixun_list[$value]['brand_id'],
  1983. 'companyNo' => $good_zixun_list[$value]['companyNo'],
  1984. 'good_unit' => $good_zixun_list[$value]['good_unit'],
  1985. 'good_type' => $good_zixun_list[$value]['good_type'],
  1986. 'moq' => $good_zixun_list[$value]['moq'],
  1987. 'customized' => $good_zixun_list[$value]['customized'],
  1988. 'tax' => $good_zixun_list[$value]['tax'],
  1989. 'supplierNo' => $good_zixun_list[$value]['supplierNo'],
  1990. 'is_auth' => $good_zixun_list[$value]['is_auth'],
  1991. 'auth_img' => $good_zixun_list[$value]['auth_img'],
  1992. 'after_sales' => '',
  1993. 'craft_desc' => $good_zixun_list[$value]['craft_desc'],
  1994. 'good_remark' => $good_zixun_list[$value]['good_remark'],
  1995. 'weight' => $good_zixun_list[$value]['weight'],
  1996. 'packing_way' => '',
  1997. 'packing_size' => '',
  1998. 'packing_spec' => '',
  1999. 'packing_list' => '',
  2000. 'packing_weight' => '',
  2001. 'good_bar' => '',
  2002. 'supply_area' => $good_zixun_list[$value]['supply_area'],
  2003. 'delivery_place' => '',
  2004. 'origin_place' => '',
  2005. 'delivery_day' => '',
  2006. 'lead_time' => '',
  2007. 'sample_day' => '',
  2008. 'sample_fee' => '',
  2009. 'good_img' => '',//$good_zixun_list[$value]['good_img'],
  2010. 'good_thumb_img' => $good_zixun_list[$value]['good_thumb_img'],
  2011. 'good_info_img' => $good_zixun_list[$value]['good_img'],//商品主图对应到商品详情
  2012. 'cert_fee' => '',
  2013. 'packing_fee' => '',
  2014. 'cost_fee' => '',
  2015. 'mark_fee' => '',
  2016. 'demo_fee' => '',
  2017. 'open_fee' => '',
  2018. 'noble_metal' => $good_zixun_list[$value]['noble_metal'],
  2019. 'noble_weight' => $good_zixun_list[$value]['good_weight'],
  2020. 'is_gold_price' => $good_zixun_list[$value]['is_gold_price'],
  2021. 'cgd_gold_price' => '',
  2022. 'market_price' => '',
  2023. 'nake_price' => '',
  2024. 'is_step' => '',
  2025. 'is_online' => '',
  2026. 'status' => 8,//咨询商品待编辑
  2027. 'createrid' => $createrid,
  2028. 'creater' => $creater,
  2029. 'field_change' => '',
  2030. 'is_del' => 0,
  2031. 'addtime' => date('Y-m-d H:i:s'),
  2032. 'updatetime' => date('Y-m-d H:i:s'),
  2033. 'is_diff' => $good_zixun_list[$value]['is_diff'],
  2034. 'config' => $good_zixun_list[$value]['config'],
  2035. 'other_config' => $good_zixun_list[$value]['other_config'],
  2036. ];
  2037. }
  2038. //good_spec
  2039. if (!empty($good_zixun_list[$value]['specinfo'])) {
  2040. $spec_list = json_decode($good_zixun_list[$value]['specinfo'], true);
  2041. foreach ($spec_list as $spec) {
  2042. $temp = Db::name('good_spec')
  2043. ->field('id')
  2044. ->where(['spuCode' => $value, 'spec_id' => $spec['specid'], 'spec_value_id' => $spec['spec_value_id'], 'is_del' => 0])
  2045. ->find();
  2046. if (!empty($temp)) {
  2047. $good_spec_insert_data[] = [
  2048. 'spuCode' => $value,
  2049. 'spec_id' => $spec['specid'],
  2050. 'spec_value_id' => $spec['spec_value_id'],
  2051. 'is_del' => 0,
  2052. 'addtime' => date('Y-m-d H:i:s'),
  2053. 'updatetime' => date('Y-m-d H:i:s'),
  2054. ];
  2055. }
  2056. }
  2057. }
  2058. $i++;
  2059. }
  2060. if (!empty($isonline)) {
  2061. return app_show(1009, "存在已上线产品", $isonline);
  2062. }
  2063. Db::startTrans();
  2064. try {
  2065. $create = Db::name("good_platform")->insertAll($data);
  2066. Db::name("good_zixun")
  2067. ->where(["is_del" => 0, 'status' => 1])
  2068. ->whereIn('spuCode', $param['codes'])
  2069. ->update(['status' => 2, 'updatetime' => date('Y-m-d H:i:s')]);
  2070. if (!empty($good_insert_data)) Db::name('good')->insertAll($good_insert_data);
  2071. if (!empty($good_basic_insert_data)) Db::name('good_basic')->insertAll($good_basic_insert_data);
  2072. if (!empty($good_spec_insert_data)) Db::name('good_spec')->insertAll($good_spec_insert_data);
  2073. if ($create) {
  2074. foreach ($good_zixun_list as $value) {
  2075. //添加审核记录
  2076. //修改状态,添加待办
  2077. $skuCodes = array_column($data, 'skuCode', 'spuCode');
  2078. ActionLog::logAdd(['id' => $createrid, 'nickname' => $creater], [
  2079. "order_code" => $skuCodes[$value['spuCode']],//
  2080. "status" => 2,//待产品审核
  2081. "action_remark" => '',//备注
  2082. "action_type" => "create"//新建create,编辑edit,更改状态status
  2083. ], "SPSX", $value['status'], $value);
  2084. ProcessOrder::AddProcess(['id' => $createrid, 'nickname' => $creater], [
  2085. "order_type" => 'SPSX',
  2086. "order_code" => $skuCodes[$value['spuCode']],//
  2087. "order_id" => isset($value['id']) ? $value['id'] : 0,
  2088. "order_status" => 2,//待产品审核
  2089. ]);
  2090. }
  2091. Db::commit();
  2092. return app_show(0, "提交成功");
  2093. } else {
  2094. Db::rollback();
  2095. return error_show(1004, "提交失败");
  2096. }
  2097. } catch (Exception $exception) {
  2098. Db::rollback();
  2099. return error_show(1005, $exception->getMessage());
  2100. }
  2101. }
  2102. }