123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746 |
- <?php
- // +----------------------------------------------------------------------
- // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
- // +----------------------------------------------------------------------
- // | Author: CRMEB Team <admin@crmeb.com>
- // +----------------------------------------------------------------------
- declare (strict_types=1);
- namespace app\services\user;
- use app\services\BaseServices;
- use app\dao\user\UserBillDao;
- use app\services\user\level\UserLevelServices;
- use think\Exception;
- use think\exception\ValidateException;
- use crmeb\services\CacheService;
- use think\facade\Log;
- /**
- *
- * Class UserBillServices
- * @package app\services\user
- * @mixin UserBillDao
- */
- class UserBillServices extends BaseServices
- {
- /**
- * 用户记录模板
- * @var array[]
- */
- protected $incomeData = [
- 'pay_give_integral' => [
- 'title' => '购买商品赠送消费分',
- 'category' => 'integral',
- 'type' => 'gain',
- 'mark' => '购买商品赠送{%num%}消费分',
- 'status' => 1,
- 'pm' => 1
- ],
- 'order_give_integral' => [
- 'title' => '下单赠送消费分',
- 'category' => 'integral',
- 'type' => 'gain',
- 'mark' => '下单赠送{%num%}消费分',
- 'status' => 1,
- 'pm' => 1
- ],
- 'integral_day_send' => [
- 'title' => '参考分每日释放',
- 'category' => 'award_integral',
- 'type' => 'day_send',
- 'mark' => '每日释放{%num%}参考分',
- 'status' => 1,
- 'pm' => 1
- ],
- 'integral_speed_up' => [
- 'title' => '参考分加速释放',
- 'category' => 'award_integral',
- 'type' => 'speed_up',
- 'mark' => '加速释放{%num%}参考分',
- 'status' => 1,
- 'pm' => 1
- ],
- 'extract_award_integral' => [
- 'title' => '参考分提取',
- 'category' => 'award_integral',
- 'type' => 'extract',
- 'mark' => '提取{%num%}参考分',
- 'status' => 1,
- 'pm' => 0
- ],
- 'order_promotions_give_integral' => [
- 'title' => '下单优惠活动赠送消费分',
- 'category' => 'integral',
- 'type' => 'gain',
- 'mark' => '下单优惠活动赠送{%num%}消费分',
- 'status' => 1,
- 'pm' => 1
- ],
- 'order_give_exp' => [
- 'title' => '下单赠送经验',
- 'category' => 'exp',
- 'type' => 'gain',
- 'mark' => '下单赠送{%num%}经验',
- 'status' => 1,
- 'pm' => 1
- ],
- 'integral_refund' => [
- 'title' => '消费分回退',
- 'category' => 'integral',
- 'type' => 'deduction',
- 'mark' => '购买商品失败,回退{%num%}消费分',
- 'status' => 1,
- 'pm' => 0
- ],
- 'order_integral_refund' => [
- 'title' => '返还下单使用消费分',
- 'category' => 'integral',
- 'type' => 'integral_refund',
- 'mark' => '购买商品失败,回退{%num%}消费分',
- 'status' => 1,
- 'pm' => 1
- ],
- 'pay_product_integral_back' => [
- 'title' => '商品退消费分',
- 'category' => 'integral',
- 'type' => 'pay_product_integral_back',
- 'mark' => '订单返还{%num%}消费分',
- 'status' => 1,
- 'pm' => 1
- ],
- 'deduction' => [
- 'title' => '消费分抵扣',
- 'category' => 'integral',
- 'type' => 'deduction',
- 'mark' => '购买商品使用{%number%}消费分抵扣{%deductionPrice%}元',
- 'status' => 1,
- 'pm' => 0
- ],
- 'lottery_use_integral' => [
- 'title' => '参与抽奖使用消费分',
- 'category' => 'integral',
- 'type' => 'lottery_use',
- 'mark' => '参与抽奖使用{%num%}消费分',
- 'status' => 1,
- 'pm' => 0
- ],
- 'lottery_give_integral' => [
- 'title' => '抽奖中奖赠送消费分',
- 'category' => 'integral',
- 'type' => 'lottery_add',
- 'mark' => '抽奖中奖赠送{%num%}消费分',
- 'status' => 1,
- 'pm' => 1
- ],
- 'storeIntegral_use_integral' => [
- 'title' => '消费分兑换商品',
- 'category' => 'integral',
- 'type' => 'storeIntegral_use',
- 'mark' => '消费分商城兑换商品使用{%num%}消费分',
- 'status' => 1,
- 'pm' => 0
- ],
- 'system_clear_integral' => [
- 'title' => '到期自动清除消费分',
- 'category' => 'integral',
- 'type' => 'system_clear',
- 'mark' => '到期自动清除{%num%}消费分',
- 'status' => 1,
- 'pm' => 0
- ],
- 'newcomer_give_integral' => [
- 'title' => '新人礼赠送消费分',
- 'category' => 'integral',
- 'type' => 'newcomer_add',
- 'mark' => '新人礼赠送{%num%}消费分',
- 'status' => 1,
- 'pm' => 1
- ],
- 'level_give_integral' => [
- 'title' => '会员卡激活赠送消费分',
- 'category' => 'integral',
- 'type' => 'level_add',
- 'mark' => '会员卡激活赠送{%num%}消费分',
- 'status' => 1,
- 'pm' => 1
- ],
- 'system_add_integral' => [
- 'title' => '系统增加消费分',
- 'category' => 'integral',
- 'type' => 'system_add',
- 'mark' => '系统增加了{%num%}消费分',
- 'status' => 1,
- 'pm' => 1
- ],
- 'system_sub_integral' => [
- 'title' => '系统减少消费分',
- 'category' => 'integral',
- 'type' => 'system_sub',
- 'mark' => '系统扣除了{%num%}消费分',
- 'status' => 1,
- 'pm' => 0
- ],
- 'extract_integral' => [
- 'title' => '积分出局',
- 'category' => 'energy',
- 'type' => 'extract_integral',
- 'mark' => '用户{%type%}出局,出局时积分价格{%price%},共出局{%integral_num%}积分,获得{%number%}能量',
- 'status' => 1,
- 'pm' => 1
- ],
- 'extract_integral_new' => [
- 'title' => '贡献分能量',
- 'category' => 'energy',
- 'type' => 'activity_energy',
- 'mark' => '{%mark%},获得{%number%}能量',
- 'status' => 1,
- 'pm' => 1
- ],
- 'extract_integral_static' => [
- 'title' => '参考分提取能量',
- 'category' => 'energy',
- 'type' => 'static_energy',
- 'mark' => '{%mark%},获得{%number%}能量',
- 'status' => 1,
- 'pm' => 1
- ],
- 'extract_integral_shop' => [
- 'title' => '参考分提取消费分',
- 'category' => 'integral',
- 'type' => 'static_integral',
- 'mark' => '{%mark%},获得{%number%}消费分',
- 'status' => 1,
- 'pm' => 1
- ],
- 'exchange' => [
- 'title' => '能量转换',
- 'category' => 'energy',
- 'type' => 'exchange',
- 'mark' => '{%mark%},{%number%}能量转换份额',
- 'status' => 1,
- 'pm' => 0
- ],
- 'exchange_fail' => [
- 'title' => '转换失败',
- 'category' => 'energy',
- 'type' => 'exchange_fail',
- 'mark' => '转换失败,退回能量{%num%}',
- 'status' => 1,
- 'pm' => 1
- ],
- 'brokerage_to_energy' => [
- 'title' => '佣金转换到能量',
- 'category' => 'energy',
- 'type' => 'exchange_to_energy',
- 'mark' => '佣金转换到能量{%num%}',
- 'status' => 1,
- 'pm' => 1
- ],
- 'trade_in_shop_integral' => [
- 'title' => '消费分转入',
- 'category' => 'integral',
- 'type' => 'trade_in',
- 'mark' => '{%mark%},到账{%number%}',
- 'status' => 1,
- 'pm' => 1
- ],
- 'trade_out_shop_integral' => [
- 'title' => '消费分转出',
- 'category' => 'integral',
- 'type' => 'trade_out',
- 'mark' => '{%mark%}{%origin%},转账手续费{%fee%},合计{%number%}',
- 'status' => 1,
- 'pm' => 0
- ],
- ];
- /**
- * UserBillServices constructor.
- * @param UserBillDao $dao
- */
- public function __construct(UserBillDao $dao)
- {
- $this->dao = $dao;
- }
- /**
- * 获取用户记录总和
- * @param $uid
- * @param string $category
- * @param array $type
- * @return mixed
- */
- public function getRecordCount(int $uid, $category = 'now_money', $type = [], $time = '', $pm = false)
- {
- $where = [];
- $where['uid'] = $uid;
- $where['category'] = $category;
- $where['status'] = 1;
- if (is_string($type) && strlen(trim($type))) {
- $where['type'] = explode(',', $type);
- }
- if ($time) {
- $where['time'] = $time;
- }
- $where['pm'] = $pm ? 1 : 0;
- return $this->dao->getBillSumColumn($where);
- }
- /**
- * 获取积分列表
- * @param int $uid
- * @param array $where_time
- * @param string $field
- * @return array
- */
- public function getIntegralList(int $uid = 0, $where_time = [], string $field = '*')
- {
- [$page, $limit] = $this->getPageValue();
- $where = ['category' => 'integral'];
- if ($uid) $where['uid'] = $uid;
- if ($where_time) $where['add_time'] = $where_time;
- $list = $this->dao->getList($where, $field, $page, $limit);
- foreach ($list as &$item) {
- $item['number'] = intval($item['number']);
- $item['balance'] = intval($item['balance']);
- }
- $count = $this->dao->count($where);
- return compact('list', 'count');
- }
- /**
- * 获取积分列表
- * @param int $uid
- * @param array $where_time
- * @param string $field
- * @return array
- */
- public function getEnergyList(int $uid = 0, $where_time = [], string $field = '*')
- {
- [$page, $limit] = $this->getPageValue();
- $where = ['category' => 'energy'];
- if ($uid) $where['uid'] = $uid;
- if ($where_time) $where['add_time'] = $where_time;
- $list = $this->dao->getList($where, $field, $page, $limit);
- foreach ($list as &$item) {
- $item['number'] = intval($item['number']);
- $item['balance'] = intval($item['balance']);
- }
- $count = $this->dao->count($where);
- return compact('list', 'count');
- }
- /**
- * 获取签到列表
- * @param int $uid
- * @param array $where_time
- * @param string $field
- * @return array
- */
- public function getSignList(int $uid = 0, $where_time = [], string $field = '*')
- {
- [$page, $limit] = $this->getPageValue();
- $where = ['category' => 'integral', 'type' => 'sign'];
- if ($uid) $where['uid'] = $uid;
- if ($where_time) $where['add_time'] = $where_time;
- $list = $this->dao->getList($where, $field, $page, $limit);
- $count = $this->dao->count($where);
- return compact('list', 'count');
- }
- /**
- * 经验总数
- * @param int $uid
- * @param array $where_time
- * @return float
- */
- public function getExpSum(int $uid = 0, $where_time = [])
- {
- $where = ['category' => ['exp'], 'pm' => 1, 'status' => 1];
- if ($uid) $where['uid'] = $uid;
- if ($where_time) $where['time'] = $where_time;
- return $this->dao->getBillSum($where);
- }
- /**
- * 获取所有经验列表
- * @param int $uid
- * @param array $where_time
- * @param string $field
- * @return array
- */
- public function getExpList(int $uid = 0, $where_time = [], string $field = '*')
- {
- [$page, $limit] = $this->getPageValue();
- $where = ['category' => ['exp']];
- $where['status'] = 1;
- if ($uid) $where['uid'] = $uid;
- if ($where_time) $where['time'] = $where_time;
- $list = $this->dao->getList($where, $field, $page, $limit);
- $count = $this->dao->count($where);
- return compact('list', 'count');
- }
- /**
- * 记录积分变化
- * @param int $uid
- * @param string $type
- * @param array $data
- * @param int $pm
- * @return bool
- * @throws Exception
- */
- public function incomeIntegral(int $uid, string $type, array $data, int $pm = 1)
- {
- $data['uid'] = $uid;
- $data['category'] = 'integral';
- $data['type'] = $type;
- $data['pm'] = $pm;
- $data['status'] = 1;
- $data['add_time'] = time();
- if (!$this->dao->save($data))
- throw new Exception('增加记录失败');
- return true;
- }
- /**
- * 写入用户记录
- * @param string $type 写入类型
- * @param int $uid
- * @param int|string|array $number
- * @param int|string $balance
- * @param int $link_id
- * @return bool|mixed
- */
- public function income(string $type, int $uid, $number, $balance, $link_id = 0)
- {
- $data = $this->incomeData[$type] ?? null;
- if (!$data) {
- return true;
- }
- $data['uid'] = $uid;
- $data['balance'] = $balance ?? 0;
- $data['link_id'] = $link_id;
- if (is_array($number)) {
- $key = array_keys($number);
- $key = array_map(function ($item) {
- return '{%' . $item . '%}';
- }, $key);
- $value = array_values($number);
- $data['number'] = $number['number'] ?? 0;
- $data['mark'] = str_replace($key, $value, $data['mark']);
- } else {
- $data['number'] = $number;
- $data['mark'] = str_replace(['{%num%}'], $number, $data['mark']);
- }
- $data['add_time'] = time();
- if ((float)$data['number']) {
- return $this->dao->save($data);
- }
- return true;
- }
- /**
- * 邀请新用户增加经验
- * @param int $spreadUid
- */
- public function inviteUserIncExp(int $spreadUid)
- {
- if (!$spreadUid) {
- return false;
- }
- //用户等级是否开启
- if (!sys_config('member_func_status', 1)) {
- return false;
- }
- /** @var UserServices $userService */
- $userService = app()->make(UserServices::class);
- $spread_user = $userService->getUserInfo($spreadUid);
- if (!$spread_user) {
- return false;
- }
- $exp_num = sys_config('invite_user_exp', 0);
- if ($exp_num) {
- $userService->incField($spreadUid, 'exp', (int)$exp_num);
- $data = [];
- $data['uid'] = $spreadUid;
- $data['number'] = $exp_num;
- $data['category'] = 'exp';
- $data['type'] = 'invite_user';
- $data['title'] = $data['mark'] = '邀新奖励';
- $data['balance'] = (int)$spread_user['exp'];
- $data['pm'] = 1;
- $data['status'] = 1;
- $this->dao->save($data);
- }
- //检测会员等级
- try {
- /** @var UserLevelServices $levelServices */
- $levelServices = app()->make(UserLevelServices::class);
- //检测会员升级
- $levelServices->detection($spreadUid);
- } catch (\Throwable $e) {
- Log::error('会员等级升级失败,失败原因:' . $e->getMessage());
- }
- return true;
- }
- /**
- * 获取type
- * @param array $where
- * @param string $filed
- */
- public function getBillType(array $where)
- {
- return $this->dao->getType($where);
- }
- /**
- * 资金类型
- */
- public function bill_type()
- {
- $where = [];
- $where['not_type'] = ['gain', 'system_sub', 'deduction', 'sign'];
- $where['not_category'] = ['exp', 'integral'];
- return CacheService::get('user_type_list', function () use ($where) {
- return ['list' => $this->dao->getType($where)];
- }, 600);
- }
- /**
- * 记录分享次数
- * @param int $uid 用户uid
- * @param int $cd 冷却时间
- * @return Boolean
- * */
- public function setUserShare(int $uid, $cd = 300)
- {
- /** @var UserServices $userServices */
- $userServices = app()->make(UserServices::class);
- $user = $userServices->getUserInfo($uid);
- if (!$user) {
- throw new ValidateException('用户不存在!');
- }
- $cachename = 'Share_' . $uid;
- if (CacheService::get($cachename)) {
- return false;
- }
- $data = ['title' => '用户分享记录', 'uid' => $uid, 'category' => 'share', 'type' => 'share', 'number' => 0, 'link_id' => 0, 'balance' => 0, 'mark' => date('Y-m-d H:i:s', time()) . ':用户分享'];
- if (!$this->dao->save($data)) {
- throw new ValidateException('记录分享记录失败');
- }
- CacheService::set($cachename, 1, $cd);
- return true;
- }
- /**
- * 获取积分列表
- * @param array $where
- * @param string $field
- * @param int $limit
- * @return array
- */
- public function getPointList(array $where, string $field = '*', int $limit = 0)
- {
- $where_data = [];
- $where_data['category'] = 'integral';
- if (isset($where['uid']) && $where['uid'] != '') {
- $where_data['uid'] = $where['uid'];
- }
- if ($where['start_time'] != '' && $where['end_time'] != '') {
- $where_data['time'] = $where['start_time'] . ' - ' . $where['end_time'];
- }
- if (isset($where['type']) && $where['type'] != '') {
- $where_data['type'] = $where['type'];
- }
- if (isset($where['nickname']) && $where['nickname'] != '') {
- $where_data['like'] = $where['nickname'];
- }
- if (isset($where['excel']) && $where['excel'] != '') {
- $where_data['excel'] = $where['excel'];
- } else {
- $where_data['excel'] = 0;
- }
- if ($limit) {
- [$page] = $this->getPageValue();
- } else {
- [$page, $limit] = $this->getPageValue();
- }
- $list = $this->dao->getBillList($where_data, $field, $page, $limit);
- foreach ($list as &$item) {
- $item['nickname'] = $item['user']['nickname'] ?? '';
- $item['number'] = intval($item['number']);
- $item['balance'] = intval($item['balance']);
- unset($item['user']);
- }
- $count = $this->dao->count($where_data);
- return compact('list', 'count');
- }
- /**
- * 积分头部信息
- * @param array $where
- * @return array[]
- */
- public function getUserPointBadgelist(array $where)
- {
- $data = [];
- $where_data = [];
- $where_data['category'] = 'integral';
- if ($where['start_time'] != '' && $where['end_time'] != '') {
- $where_data['time'] = $where['start_time'] . ' - ' . $where['end_time'];
- }
- if (isset($where['nickname']) && $where['nickname'] != '') {
- $where_data['like'] = $where['nickname'];
- }
- $data['SumIntegral'] = intval($this->dao->getBillSumColumn($where_data + ['pm' => 1]));
- $where_data['type'] = 'sign';
- $data['CountSign'] = $this->dao->getUserSignPoint($where_data);
- $data['SumSign'] = intval($this->dao->getBillSumColumn($where_data));
- unset($where_data['type']);
- $data['SumDeductionIntegral'] = intval($this->dao->getBillSumColumn($where_data + ['pm' => 0]));
- return [
- [
- 'col' => 6,
- 'count' => $data['SumIntegral'],
- 'name' => '总积分(个)',
- ],
- [
- 'col' => 6,
- 'count' => $data['CountSign'],
- 'name' => '客户签到次数(次)',
- ],
- [
- 'col' => 6,
- 'count' => $data['SumSign'],
- 'name' => '签到送出积分(个)',
- ],
- [
- 'col' => 6,
- 'count' => $data['SumDeductionIntegral'],
- 'name' => '使用积分(个)',
- ],
- ];
- }
- /**
- * @param $uid
- * @param $type
- * @return array
- */
- public function getUserBillList(int $uid, int $type)
- {
- $where = [];
- $where['uid'] = $uid;
- $where['category'] = 'now_money';
- switch ((int)$type) {
- case 0:
- $where['type'] = ['recharge', 'pay_money', 'system_add', 'pay_product_refund', 'system_sub', 'pay_member', 'offline_scan', 'lottery_use', 'lottery_add'];
- break;
- case 1:
- $where['type'] = ['pay_money', 'pay_member', 'offline_scan', 'user_recharge_refund', 'lottery_use'];
- break;
- case 2:
- $where['type'] = ['recharge', 'system_add', 'lottery_add'];
- break;
- case 3:
- $where['type'] = ['brokerage', 'brokerage_user'];
- break;
- case 4:
- $where['type'] = ['extract'];
- break;
- }
- $field = 'FROM_UNIXTIME(add_time,"%Y-%m") as time,group_concat(id SEPARATOR ",") ids';
- [$page, $limit] = $this->getPageValue();
- $list = $this->dao->getUserBillListByGroup($where, $field, 'time', $page, $limit);
- $data = [];
- if ($list) {
- $listIds = array_column($list, 'ids');
- $ids = [];
- foreach ($listIds as $id) {
- $ids = array_merge($ids, explode(',', $id));
- }
- $info = $this->dao->getColumn([['id', 'in', $ids]], 'FROM_UNIXTIME(add_time,"%Y-%m-%d %H:%i") as add_time,title,number,pm', 'id');
- foreach ($list as $item) {
- $value['time'] = $item['time'];
- $id = explode(',', $item['ids']);
- array_multisort($id, SORT_DESC);
- $value['list'] = [];
- foreach ($id as $v) {
- if (isset($info[$v])) {
- $value['list'][] = $info[$v];
- }
- }
- array_push($data, $value);
- }
- }
- return $data;
- }
- public function shop_integral_trade(int $uid, int $to_uid, $num)
- {
- /** @var UserServices $userService */
- $userService = app()->make(UserServices::class);
- $user = $userService->getUserInfo($uid);
- $to_user = $userService->getUserInfo($to_uid);
- if ($user['is_shop'] && $to_user['is_shop']) throw new ValidateException('商家只可转给用户');
- if (!$user['is_shop'] && !$to_user['is_shop']) throw new ValidateException('用户只可转给商家');
- $switch = sys_config('shop_integral_trade_switch', 1);
- $commission = sys_config('shop_integral_trade_commission', 8);
- if ($user['is_shop']) $commission = sys_config('shop_integral_trade_commission_shop', 3);
- if (!$switch) throw new ValidateException('暂不支持');
- if ($commission >= 100 || $commission < 0) throw new ValidateException('暂不支持');
- if (!$user || !$to_user) {
- throw new ValidateException('数据不存在');
- }
- $fee = bcdiv(bcmul($commission, (string)$num, 2), '100', 2);
- if ($to_uid == $uid) throw new ValidateException('不能自己转给自己');
- if ($user['is_auth'] != 2) throw new ValidateException('请先完成实名认证');
- $extractPrice = $user['integral'];
- if ($num + $fee > $extractPrice) {
- throw new ValidateException('转账消费分不足' . $num);
- }
- if ($num <= 0) {
- throw new ValidateException('转账消费分大于0');
- }
- return $this->transaction(function () use ($num, $user, $to_user, $userService, $commission, $fee) {
- //修改用户佣金
- $balance = bcsub((string)$user['integral'], (string)($num + $fee), 2) ?? 0;
- $balance2 = bcadd((string)$to_user['integral'], (string)$num, 2);
- if ($user['is_shop']) $balance2 = bcadd((string)$to_user['now_money'], (string)$num, 2);
- if (!$userService->update($user['uid'], ['integral' => $balance], 'uid')) {
- throw new ValidateException('修改用户信息失败');
- }
- $this->income('trade_out_shop_integral', $user['uid'], ['mark' => '转账给' . $to_user['nickname'] . '(' . $to_user['uid'] . ')', 'origin' => $num, 'fee' => $fee, 'number' => $num + $fee], $balance, $to_user['uid']);
- if (!$user['is_shop']) {
- if (!$userService->update($to_user['uid'], ['integral' => $balance2], 'uid')) {
- throw new ValidateException('修改用户信息失败');
- }
- $this->income('trade_in_shop_integral', $to_user['uid'], ['mark' => '转账自' . $user['nickname'] . '(' . $user['uid'] . ')', 'number' => $num], $balance2, $user['uid']);
- } else {
- $server = app()->make(UserMoneyServices::class);
- if (!$userService->update($to_user['uid'], ['now_money' => $balance2], 'uid')) {
- throw new ValidateException('修改用户信息失败');
- }
- $server->income('trade_in_shop_integral', $to_user['uid'], ['mark' => '转账自' . $user['nickname'] . '(' . $user['uid'] . ')', 'number' => $num], $balance2, $user['uid']);
- }
- //保存佣金记录
- return true;
- });
- }
- }
|