|
|
@@ -192,6 +192,15 @@ class EnshrineService extends BaseService
|
|
|
$params = request()->all();
|
|
|
switch($type){
|
|
|
case 1: // 祈福
|
|
|
+ $limitNum = ConfigService::make()->getConfigByCode('qifu_limit');
|
|
|
+ if($limitNum) {
|
|
|
+ $num = $this->model::where(['user_id'=> $userId,'mark'=> 1,'status'=> 1])
|
|
|
+ ->count('id');
|
|
|
+ if($num >= $limitNum){
|
|
|
+ return message("最多只能同时供奉{$limitNum}尊佛像,请送圣后再操作", false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
$record = $this->model::where(['fo_id'=> $id,'user_id'=> $userId,'mark'=> 1,'status'=> 1])
|
|
|
->select(['id','fo_id','user_id'])
|
|
|
->first();
|
|
|
@@ -257,4 +266,88 @@ class EnshrineService extends BaseService
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 供奉操作记录
|
|
|
+ * @param $userId
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+ public function actionRecord($userId){
|
|
|
+ $params = request()->all();
|
|
|
+ $id = isset($params['id'])? $params['id'] : 0;
|
|
|
+ $type = isset($params['type'])? $params['type'] : 0;
|
|
|
+ if($id<=0 || $type <=0){
|
|
|
+ return message('参数错误', false);
|
|
|
+ }
|
|
|
+
|
|
|
+ $enshrine = $this->model::where(['id'=> $id,'user_id'=> $userId,'mark'=> 1,'status'=> 1])
|
|
|
+ ->select(['id','fo_id','user_id'])
|
|
|
+ ->first();
|
|
|
+ if(!$enshrine){
|
|
|
+ return message('供奉记录信息不存在,无法操作', false);
|
|
|
+ }
|
|
|
+
|
|
|
+ $info = EnshrineActionModel::where(['source_id'=> $id,'user_id'=> $userId,'type'=> $type,'mark'=>1 ,'status'=> 1])
|
|
|
+ ->where('create_time','>=', time()-3600)
|
|
|
+ ->value('id');
|
|
|
+ if($info){
|
|
|
+ return message('1小时内只能操作一次,请稍后再来', false);
|
|
|
+ }
|
|
|
+
|
|
|
+ $memberInfo = MemberModel::where(['id'=> $userId,'mark'=> 1,'status'=> 1])
|
|
|
+ ->select(['id','nickname','merits_num'])
|
|
|
+ ->first();
|
|
|
+ if(!$memberInfo){
|
|
|
+ return message('您的账号不可操作或已冻结,请联系客服', false);
|
|
|
+ }
|
|
|
+
|
|
|
+ \DB::beginTransaction();
|
|
|
+ $data = [
|
|
|
+ 'source_id'=> $id,
|
|
|
+ 'user_id'=> $userId,
|
|
|
+ 'type'=> $type,
|
|
|
+ 'create_time'=> time(),
|
|
|
+ 'update_time'=> time(),
|
|
|
+ 'status'=> 1
|
|
|
+ ];
|
|
|
+ if(!EnshrineActionModel::insertGetId($data)) {
|
|
|
+ \DB::rollBack();
|
|
|
+ return message('操作失败', false);
|
|
|
+ }
|
|
|
+
|
|
|
+ $giveGd = 0;
|
|
|
+ $fields = ['1'=> 'qifu_guibai_give_gd','2'=> 'qifu_wash_give_gd'];
|
|
|
+ $field = isset($fields[$type])? $fields[$type] : '';
|
|
|
+ if($field){
|
|
|
+ $giveGd = ConfigService::make()->getConfigByCode($field);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 功德值
|
|
|
+ if($giveGd>0){
|
|
|
+ $data = [
|
|
|
+ 'user_id'=> $userId,
|
|
|
+ 'source_uid'=> 0,
|
|
|
+ 'type'=> 3,
|
|
|
+ 'coin_type'=> 4,
|
|
|
+ 'pay_type'=> 4,
|
|
|
+ 'money'=> $giveGd,
|
|
|
+ 'change_type'=> 1,
|
|
|
+ 'balance'=> $memberInfo->merits_num,
|
|
|
+ 'create_time'=> time(),
|
|
|
+ 'remark'=> $type==1? "跪拜祈福":'洗手祈福',
|
|
|
+ 'status'=> 1,
|
|
|
+ ];
|
|
|
+ if(!$this->model::insertGetId($data)){
|
|
|
+ \DB::rollBack();
|
|
|
+ return message("处理功德奖励失败", false);
|
|
|
+ }
|
|
|
+
|
|
|
+ \DB::commit();
|
|
|
+ return message("获得功德值{$giveGd}", true);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ \DB::commit();
|
|
|
+ return message("操作成功", true);
|
|
|
+ }
|
|
|
}
|