|
@@ -4,6 +4,7 @@ namespace app\mainapp\controller;
|
|
|
|
|
|
use app\common\model\Feedback;
|
|
|
use app\common\model\ResumeInvite;
|
|
|
+use app\common\model\UserBalance as UserBalanceModel;
|
|
|
use app\common\model\UserGetmoneyLog as UserGetmoneyLogModel;
|
|
|
use app\common\model\UserGetmoneyLog;
|
|
|
use app\common\model\UserWill;
|
|
@@ -292,6 +293,24 @@ class My extends BaseController
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 我的钱包
|
|
|
+ */
|
|
|
+ public function myBag()
|
|
|
+ {
|
|
|
+ $userid = input('userid/d', 0);
|
|
|
+ $user = UserModel::findOrEmpty($userid);
|
|
|
+ if ($user->isEmpty()) {
|
|
|
+ page_result(1, "用户信息不存在。");
|
|
|
+ }
|
|
|
+ $month_time = date('Ym', strtotime('-1 month'));
|
|
|
+ $month_balance = UserBalanceModel::where(['monthtime' => $month_time, 'userid' => $userid])->sum('value');
|
|
|
+ page_result(0, "", [
|
|
|
+ 'user' => $user,
|
|
|
+ 'month_balance' => $month_balance,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
public function getRecharge()
|
|
|
{
|
|
|
$userid = input('userid/d', 0);
|
|
@@ -407,6 +426,21 @@ class My extends BaseController
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
+ public function getBag()
|
|
|
+ {
|
|
|
+ $ppage = input('ppage/d', 1);
|
|
|
+ $psize = input('psize/d', 20);
|
|
|
+ $userid = input('userid/d', 0);
|
|
|
+ if ($userid != 0) {
|
|
|
+ $map[] = ['userid', '=', $userid];
|
|
|
+ }
|
|
|
+ $plist = UserBalanceModel::where($map)->order(['id' => 'desc'])->page($ppage)->limit($psize)->select();
|
|
|
+ page_result(0, "", [
|
|
|
+ 'plist' => $plist,
|
|
|
+ 'pstatus' => $psize > count($plist) ? 'noMore' : 'more',
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
// 银行卡信息
|
|
|
public function editUserBankinfo()
|
|
|
{
|
|
@@ -459,7 +493,7 @@ class My extends BaseController
|
|
|
$user->save();
|
|
|
//发放佣金
|
|
|
$balanceService = new BalanceService();
|
|
|
- $balanceService->add($userid,BalanceService::IMPROVERESUME);
|
|
|
+ $balanceService->add($userid, BalanceService::IMPROVERESUME);
|
|
|
}
|
|
|
/*$integralService = new IntegralService();
|
|
|
$integralService->add($userid, IntegralService::IMPROVERESUME);*/
|
|
@@ -636,16 +670,17 @@ class My extends BaseController
|
|
|
|
|
|
//满足提现条件
|
|
|
$user = UserModel::findOrEmpty($userid);
|
|
|
- if ($user['integral'] < ($cash['money'] * $param['inttomoney'])) {
|
|
|
- page_result(1, "积分不足");
|
|
|
+ if ($user['balance'] < $cash['money']) {
|
|
|
+ page_result(1, "余额不足");
|
|
|
}
|
|
|
$where = [
|
|
|
['userid', '=', $userid],
|
|
|
['money', '=', $cash['money']],
|
|
|
];
|
|
|
if ($cash['type'] == 2) {
|
|
|
- $where = ['createtime', '>=', strtotime(date('Y-m-01'))];
|
|
|
+ $where[] = ['createtime', '>=', strtotime(date('Y-m-01'))];
|
|
|
}
|
|
|
+
|
|
|
$cash_count = UserGetmoneyLog::where($where)->count();
|
|
|
if ($cash_count >= $cash['num']) {
|
|
|
page_result(1, "超过次数限制");
|
|
@@ -659,34 +694,30 @@ class My extends BaseController
|
|
|
$transfers = new WechatTransfers();
|
|
|
$detail[] = $transfers->getDetailList($out_trade_no, $cash['money'], $batch_name, $openid);
|
|
|
$res = $transfers->transfers($batch_name, $detail);
|
|
|
- Log::record('用户提现:'.json_encode($res));
|
|
|
+ Log::record('用户提现:' . json_encode($res));
|
|
|
|
|
|
//记录
|
|
|
if (!empty($res['batch_id'])) {
|
|
|
- $point = $cash['money'] * $param['inttomoney'];
|
|
|
UserGetmoneyLog::create([
|
|
|
'userid' => $userid,
|
|
|
'out_trade_no' => $out_trade_no,
|
|
|
'money' => $cash['money'],
|
|
|
- 'integral' => $point,
|
|
|
'remark' => '小程序用户提现',
|
|
|
'createtime' => time(),
|
|
|
]);
|
|
|
- $integral = new UserIntegralModel;
|
|
|
- $integral->save([
|
|
|
- 'userid' => $userid,
|
|
|
- 'title' => "用户提现",
|
|
|
- 'intvalue' => $point,
|
|
|
- 'intmoney' => 0.00,
|
|
|
- 'onlycontent' => "",
|
|
|
- 'remark' => "积分提现活动",
|
|
|
- 'itype' => 3,
|
|
|
- 'status' => 2,
|
|
|
- 'createtime' => time(),
|
|
|
- 'yeartime' => date("Y"),
|
|
|
- 'monthtime' => date("Ym"),
|
|
|
+ $balance = new UserBalanceModel();
|
|
|
+ $balance->save([
|
|
|
+ 'userid' => $userid,
|
|
|
+ 'title' => "用户提现",
|
|
|
+ 'origin_value' => $user->balance,
|
|
|
+ 'value' => $cash['money'],
|
|
|
+ 'remark' => "余额提现",
|
|
|
+ 'status' => 2,
|
|
|
+ 'createtime' => time(),
|
|
|
+ 'yeartime' => date("Y"),
|
|
|
+ 'monthtime' => date("Ym"),
|
|
|
]);
|
|
|
- $user->integral -= $point;
|
|
|
+ $user->balance -= $cash['money'];
|
|
|
$user->save();
|
|
|
}
|
|
|
|