public function store(Request $request) { $data = $this->getData($request); $data['created_at'] = time(); UserVoiceModel::create($data); //成功发布后给用户随机奖励金币1-5个 $gold = rand(1, 5); UserGoldModel::setGold($this->userid, 3, $gold); //计算金币总数 if ($gold) { WalletModel::setGold($this->userid, $gold); } return redirect(DOMAIN . 'uservoice'); }
/** * 设置评价、返利 */ public function setComment($id, $comment, $backGold) { if ($comment == 0) { $status = 6; } elseif ($comment == 1) { $status = 7; } OrderProductModel::where('id', $id)->where('status', 5)->update(['status' => $status]); //金币返利 if ($comment && $backGold) { UserGoldModel::setGold($this->userid, 4, $backGold); WalletModel::where('uid', $this->userid)->increment('gold', $backGold); } return redirect(DOMAIN . 'member/orderpro'); }
public function setStatus(Request $request, $id) { if ($request->status == 3 && !$request->remarks) { echo "<script>alert('请填写不满意缘由!');history.go(-1);</script>"; exit; } $data = ['status' => $request->status, 'remarks' => $request->remarks, 'updated_at' => time()]; OpinionModel::where('id', $id)->update($data); //成功发布后给用户随机奖励金币10-15个 if ($request->status == 4) { $data['gold2'] = rand(10, 15); UserGoldModel::setGold($this->userid, 2, $data['gold2']); } //计算金币总数 if (isset($data['gold2'])) { WalletModel::setGold($this->userid, $data['gold2']); } return redirect(DOMAIN . 'opinion'); }
/** * 金币查询 */ public function getGolds() { $datas = UserGoldModel::where('uid', $this->userid)->orderBy('id', 'desc')->paginate($this->limit); $datas->limit = $this->limit; return $datas; }
/** * 设置好评的返金币 */ public function setBackGold($id, $uid) { OrderProductModel::where('id', $id)->update(['status' => 8]); //更新基本数量 UserGoldModel::setGold($uid, 4, 5); $walletModel = WalletModel::where('uid', $uid)->first(); WalletModel::where('uid', $uid)->update(['gold' => $walletModel->gold + 5]); return redirect(DOMAIN . 'admin/orderpro'); }