|
@@ -82,8 +82,8 @@ class MemberService
|
|
|
}
|
|
|
$query->whereBetween('member.member_addtimes', $addtime);
|
|
|
})->when(!empty($nickname), function ($query) use ($nickname) {
|
|
|
- $query->where(function($query2) use ($nickname){
|
|
|
- $query2->where('member_info.member_info_nickname','like','%'.$nickname.'%')->orWhere('member.member_mobile','like','%'.$nickname.'%');
|
|
|
+ $query->where(function ($query2) use ($nickname) {
|
|
|
+ $query2->where('member_info.member_info_nickname', 'like', '%' . $nickname . '%')->orWhere('member.member_mobile', 'like', '%' . $nickname . '%');
|
|
|
});
|
|
|
})
|
|
|
->select('member_id', 'member_is_vip', 'member_is_owner', 'member_classify', 'member_status', 'member_mobile', 'member_from', 'member_addtimes', 'member_extend_json',
|
|
@@ -659,6 +659,60 @@ class MemberService
|
|
|
return json_success('', compact('rows', 'page', 'pageSize', 'total'));
|
|
|
}
|
|
|
|
|
|
+ public static function clearWelfare(Request $request)
|
|
|
+ {
|
|
|
+ $memberId = $request->post('member_id');
|
|
|
+ $payTime = $request->post('pay_paytimes', date('Y-m-d H:i:s'));
|
|
|
+ $payTime = date('Y-m-d H:i:s',strtotime($payTime));
|
|
|
+ $payRemark = $request->post('pay_remark', '');
|
|
|
+ $clearPwd = $request->post('clear_password');
|
|
|
+ if (!$clearPwd || $clearPwd != '123456'){
|
|
|
+ return json_fail('清零密码错误');
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::beginTransaction();
|
|
|
+ try {
|
|
|
+ $account = MemberAccount::where('join_account_member_id', $memberId)
|
|
|
+ ->where('member_account_classify', 'WELFARE')
|
|
|
+ ->where('member_account_status', 'ACTIVED')
|
|
|
+ ->first();
|
|
|
+ if (!$account) {
|
|
|
+ throw new BusinessException("账户异常");
|
|
|
+ }
|
|
|
+ if ($account->member_account_surplus <= 0){
|
|
|
+ throw new BusinessException("账户余额为0,无需清零");
|
|
|
+ }
|
|
|
+ // 创建清除记录
|
|
|
+ PayDetail::insert([
|
|
|
+ 'join_pay_member_id' => $memberId,
|
|
|
+ 'pay_status' => 'SUCCESS',
|
|
|
+ 'pay_category' => 'CLEAR',
|
|
|
+ 'pay_amount' => $account->member_account_surplus,
|
|
|
+ 'pay_paytimes' => $payTime,
|
|
|
+ 'pay_prepayid' => $memberId . '-WELFARE',
|
|
|
+ 'pay_remark' => $payRemark,
|
|
|
+ 'pay_addtimes' => time()
|
|
|
+ ]);
|
|
|
+
|
|
|
+ // 账户归零
|
|
|
+ $account->member_account_expend = $account->member_account_expend + $account->member_account_surplus;
|
|
|
+ $account->member_account_surplus = 0;
|
|
|
+ $account->save();
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+
|
|
|
+ return json_success('success');
|
|
|
+ }catch (BusinessException $e){
|
|
|
+ Db::rollBack();
|
|
|
+ return json_fail($e->getMessage());
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ dump($e->getMessage());
|
|
|
+ Db::rollBack();
|
|
|
+
|
|
|
+ return json_fail('清零失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static function balanceInfo(Request $request)
|
|
|
{
|
|
|
$memberId = $request->get('member_id', '');
|
|
@@ -741,7 +795,7 @@ class MemberService
|
|
|
|
|
|
$item['balance'] = number_format($balance, 2, '.', '');
|
|
|
$balance = $balance - $item['pay_amount'];
|
|
|
- if ($item['pay_category'] != 'GIVE'){
|
|
|
+ if ($item['pay_category'] != 'GIVE') {
|
|
|
$data[] = $item;
|
|
|
}
|
|
|
|