|
@@ -108,27 +108,29 @@ class GoodsController extends Controller
|
108
|
108
|
$goods['productCode'] = trim($request->input('productCode'));
|
109
|
109
|
$goodsCategoryName = trim($request->input('goodsCategoryName'));
|
110
|
110
|
$goodsCategoryName2 = trim($request->input('goodsCategoryName2'));
|
111
|
|
- if( !empty($goodsCategoryName2) ){
|
112
|
|
- //增加分类
|
113
|
|
- $cates = array();
|
114
|
|
- $cates['name'] = $goodsCategoryName2;
|
115
|
|
- DB::table('categorys')->insert($cates);
|
116
|
|
- $goodsCategoryName = $goodsCategoryName2;
|
117
|
|
- }
|
118
|
|
- $goods['goodsCategoryName'] = $goodsCategoryName;
|
119
|
111
|
|
120
|
|
- //图片上传 阿里云oss
|
121
|
|
- if ($request->hasFile('img') && $request->file('img')->isValid()) {
|
122
|
|
- $file = $request->file('img');
|
123
|
|
- $ossClient=new oss();
|
124
|
|
- // 上传阿里云
|
125
|
|
- $file = $ossClient->upload($file->getClientOriginalExtension(), $file->getRealPath(), 'upload/seafoodPic'.date("Y-m-d",time()).'/'.date('His'));
|
126
|
|
- $img=$file['oss-request-url'];
|
127
|
|
- $goods['picUrl']=str_replace("kx-youhuiquan.oss-cn-beijing.aliyuncs.com","imgs.726p.com",$img);
|
128
|
|
- }
|
129
|
|
- if( !isset($goods['picUrl']) ) $goods['picUrl'] = 'http://imgs.726p.com/tbk/upload/seafoodPic2019-10-14/151513/kx-5da4208175314.jpg';
|
130
|
112
|
DB::beginTransaction();
|
131
|
113
|
try{
|
|
114
|
+ if( !empty($goodsCategoryName2) ){
|
|
115
|
+ //增加分类
|
|
116
|
+ $cates = array();
|
|
117
|
+ $cates['name'] = $goodsCategoryName2;
|
|
118
|
+ DB::table('categorys')->insert($cates);
|
|
119
|
+ $goodsCategoryName = $goodsCategoryName2;
|
|
120
|
+ }
|
|
121
|
+ $goods['goodsCategoryName'] = $goodsCategoryName;
|
|
122
|
+
|
|
123
|
+ //图片上传 阿里云oss
|
|
124
|
+ if ($request->hasFile('img') && $request->file('img')->isValid()) {
|
|
125
|
+ $file = $request->file('img');
|
|
126
|
+ $ossClient=new oss();
|
|
127
|
+ // 上传阿里云
|
|
128
|
+ $file = $ossClient->upload($file->getClientOriginalExtension(), $file->getRealPath(), 'upload/seafoodPic'.date("Y-m-d",time()).'/'.date('His'));
|
|
129
|
+ $img=$file['oss-request-url'];
|
|
130
|
+ $goods['picUrl']=str_replace("kx-youhuiquan.oss-cn-beijing.aliyuncs.com","imgs.726p.com",$img);
|
|
131
|
+ }
|
|
132
|
+ if( !isset($goods['picUrl']) ) $goods['picUrl'] = 'http://imgs.726p.com/tbk/upload/seafoodPic2019-10-14/151513/kx-5da4208175314.jpg';
|
|
133
|
+
|
132
|
134
|
$res = DB::table('goods')->insertGetId($goods);
|
133
|
135
|
if($res){
|
134
|
136
|
//卖家云必要参数拼接转化
|