|
@@ -298,11 +298,23 @@ class DreamController extends Controller
|
|
if ($user->coin < $coin) {
|
|
if ($user->coin < $coin) {
|
|
return $this->error(ErrorCode::COIN_NOT_ENOUGH);
|
|
return $this->error(ErrorCode::COIN_NOT_ENOUGH);
|
|
}else{
|
|
}else{
|
|
|
|
+
|
|
$user->coin -= $coin;
|
|
$user->coin -= $coin;
|
|
$user->save();
|
|
$user->save();
|
|
$dream->get_coin += $coin;
|
|
$dream->get_coin += $coin;
|
|
$dream->mark += $coin*$number;
|
|
$dream->mark += $coin*$number;
|
|
$dream->save();
|
|
$dream->save();
|
|
|
|
+ // 梦想实现创建二维码
|
|
|
|
+ if ($dream->coin == $dream->get_coin) {
|
|
|
|
+ // 生成二维码
|
|
|
|
+ $info['transaction_id'] = date('YmdHis') . mt_rand(1000, 9999);
|
|
|
|
+ $info['code'] = 'WECHATPAY_' . $info['transaction_id'];
|
|
|
|
+ $code_url = env('APP_URL').'/user/meet?dream_id='.$dream_id;
|
|
|
|
+ $code_path = public_path('qrcodes/'.$info['code'].'.png');
|
|
|
|
+ \QrCode::format('png')->size(500)->generate($code_url,$code_path);
|
|
|
|
+ $code = env('APP_URL').'/qrcodes/'.$info['code'].'.png';
|
|
|
|
+ DreamInfoModel::where('id',$dream_id)->update(compact('code'));
|
|
|
|
+ }
|
|
$data = [
|
|
$data = [
|
|
'user_id'=>$user->id,
|
|
'user_id'=>$user->id,
|
|
'dream_id'=>$dream_id,
|
|
'dream_id'=>$dream_id,
|
|
@@ -553,6 +565,7 @@ class DreamController extends Controller
|
|
'about' => 'required',
|
|
'about' => 'required',
|
|
'coin' => 'required|integer',
|
|
'coin' => 'required|integer',
|
|
'days' => 'required|integer',
|
|
'days' => 'required|integer',
|
|
|
|
+ 'pics' => 'required|array',
|
|
],
|
|
],
|
|
[
|
|
[
|
|
'name.required' => '梦想标题必填',
|
|
'name.required' => '梦想标题必填',
|
|
@@ -561,6 +574,8 @@ class DreamController extends Controller
|
|
'coin.integer' => '梦想币必须是正整数',
|
|
'coin.integer' => '梦想币必须是正整数',
|
|
'days.required' => '实现时间必填',
|
|
'days.required' => '实现时间必填',
|
|
'days.integer' => '实现时间必须是正整数',
|
|
'days.integer' => '实现时间必须是正整数',
|
|
|
|
+ 'pics.required' => '至少上传一张图片',
|
|
|
|
+ 'pics.array' => '至少上传一张图片数组',
|
|
]
|
|
]
|
|
);
|
|
);
|
|
if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
|
|
if($validator->fails()) return $this->validatorError($validator->messages()->all(),ErrorCode::CLIENT_WRONG_PARAMS);
|
|
@@ -584,14 +599,7 @@ class DreamController extends Controller
|
|
$data['created_at'] = date('Y-m-d H:i:s');
|
|
$data['created_at'] = date('Y-m-d H:i:s');
|
|
$data['updated_at'] = date('Y-m-d H:i:s');
|
|
$data['updated_at'] = date('Y-m-d H:i:s');
|
|
$dream_id = DreamInfoModel::insertGetId($data);
|
|
$dream_id = DreamInfoModel::insertGetId($data);
|
|
-// 生成二维码
|
|
|
|
- $info['transaction_id'] = date('YmdHis') . mt_rand(1000, 9999);
|
|
|
|
- $info['code'] = 'WECHATPAY_' . $info['transaction_id'];
|
|
|
|
- $code_url = env('APP_URL').'/user/meet?dream_id='.$dream_id;
|
|
|
|
- $code_path = public_path('qrcodes/'.$info['code'].'.png');
|
|
|
|
- \QrCode::format('png')->size(500)->generate($code_url,$code_path);
|
|
|
|
- $code = env('APP_URL').'/qrcodes/'.$info['code'].'.png';
|
|
|
|
- DreamInfoModel::where('id',$dream_id)->update(compact('code'));
|
|
|
|
|
|
+
|
|
if ($dream_id) {
|
|
if ($dream_id) {
|
|
// 梦想创建成功 关联关系中最新动态+1
|
|
// 梦想创建成功 关联关系中最新动态+1
|
|
/* $info = UserCareUser::where('other_user_id',$user->id)->paginate(20);
|
|
/* $info = UserCareUser::where('other_user_id',$user->id)->paginate(20);
|