|
@@ -110,11 +110,12 @@ class Package extends Backend
|
|
|
}
|
|
|
$result = $this->model->allowField(true)->save($params);
|
|
|
|
|
|
- $this->getMiniCode($this->model->id,[],$this->auth->company_id);
|
|
|
+ $fileName = md5($this->model->id);
|
|
|
+ $fileUrl = '/uploads/package/'.$fileName.'.png';
|
|
|
+ Db::name('package')->where('id',$this->model->id)->update(['mini_code'=>$fileUrl]);
|
|
|
|
|
|
Db::commit();
|
|
|
-
|
|
|
-
|
|
|
+ $this->getMiniCode($this->model->id,[],$this->auth->company_id);
|
|
|
|
|
|
} catch (ValidateException|PDOException|Exception $e) {
|
|
|
Db::rollback();
|
|
@@ -158,11 +159,15 @@ class Package extends Backend
|
|
|
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
|
|
$row->validateFailException()->validate($validate);
|
|
|
}
|
|
|
+
|
|
|
+ $fileName = md5($ids);
|
|
|
+ $fileUrl = '/uploads/package/'.$fileName.'.png';
|
|
|
+ $params['mini_code'] = $fileUrl;
|
|
|
$result = $row->allowField(true)->save($params);
|
|
|
+ Db::commit();
|
|
|
|
|
|
$this->getMiniCode($ids,$row,$row['company_id']);
|
|
|
|
|
|
- Db::commit();
|
|
|
} catch (ValidateException|PDOException|Exception $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
@@ -191,10 +196,6 @@ class Package extends Backend
|
|
|
$code = $res2->getBody()->getContents();
|
|
|
file_put_contents(ROOT_PATH.'/public'.$fileUrl,$code);
|
|
|
|
|
|
- $companyRes = Db::name('package')->where('id',$id)->update(['mini_code'=>$fileUrl]);
|
|
|
- if ($companyRes === false) {
|
|
|
- //$this->error('生成套餐小程序码失败');
|
|
|
- }
|
|
|
$miniCode = $httpStr.$fileUrl;
|
|
|
} else {
|
|
|
$miniCode = $httpStr.$package['mini_code'];
|