添加:客户管理相关接口
This commit is contained in:
parent
90468dfe66
commit
717b148550
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\dao\user;
|
||||
|
||||
|
||||
use app\common\dao\BaseDao;
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\user\IntegralGiveRecord;
|
||||
|
||||
/**
|
||||
* Common: 商户赠送积分记录
|
||||
* Author: wu-hui
|
||||
* Time: 2023/11/10 10:36
|
||||
* Class IntegralGiveRecordDao
|
||||
* @package app\common\dao\user
|
||||
*/
|
||||
class IntegralGiveRecordDao extends BaseDao{
|
||||
/**
|
||||
* Common: 初始化模型
|
||||
* Author: wu-hui
|
||||
* Time: 2023/11/10 10:37
|
||||
* @return string
|
||||
*/
|
||||
protected function getModel(): string
|
||||
{
|
||||
return IntegralGiveRecord::class;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\model\user;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
class IntegralGiveRecord extends BaseModel
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @author xaboy
|
||||
* @day 2020-03-30
|
||||
*/
|
||||
public static function tablePk(): string
|
||||
{
|
||||
return 'record_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @author xaboy
|
||||
* @day 2020-03-30
|
||||
*/
|
||||
public static function tableName(): string
|
||||
{
|
||||
return 'integral_give_record';
|
||||
}
|
||||
|
||||
public function operateUser()
|
||||
{
|
||||
return $this->hasOne(User::class, 'operate_uid', 'uid');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->hasOne(User::class, 'uid', 'uid');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -89,7 +89,8 @@ class StoreServiceRepository extends BaseRepository
|
|||
$adminRule = [
|
||||
Elm::switches('customer', '订单管理', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(12),
|
||||
Elm::switches('is_goods', '商品管理', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(12),
|
||||
Elm::switches('is_verify', '开启核销', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开'),
|
||||
Elm::switches('is_verify', '开启核销', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(12),
|
||||
Elm::switches('is_user', '用户管理', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->col(12),
|
||||
Elm::switches('notify', '订单通知', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开')->control([
|
||||
[
|
||||
'value' => 1,
|
||||
|
|
@ -99,12 +100,11 @@ class StoreServiceRepository extends BaseRepository
|
|||
]
|
||||
])
|
||||
];
|
||||
|
||||
}
|
||||
$filed = [
|
||||
"value" => 1,
|
||||
"rule" => [
|
||||
"customer","is_goods","is_verify","notify"
|
||||
"customer","is_goods","is_verify","notify","is_user"
|
||||
]
|
||||
];
|
||||
$adminRule[] = Elm::number('sort', '排序', 0)->precision(0)->max(99999);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\common\repositories\user;
|
||||
|
||||
use app\common\dao\user\IntegralGiveRecordDao;
|
||||
use app\common\repositories\BaseRepository;
|
||||
|
||||
|
||||
/**
|
||||
* Common: ...
|
||||
* Author: wu-hui
|
||||
* Time: 2023/11/10 10:37
|
||||
* Class IntegralGiveRecordRepository
|
||||
* @package app\common\repositories\user
|
||||
*/
|
||||
class IntegralGiveRecordRepository extends BaseRepository
|
||||
{
|
||||
/**
|
||||
* @var IntegralGiveRecordDao
|
||||
*/
|
||||
protected $dao;
|
||||
/**
|
||||
* IntegralRepository constructor.
|
||||
* @param IntegralGiveRecordDao $dao
|
||||
*/
|
||||
public function __construct(IntegralGiveRecordDao $dao)
|
||||
{
|
||||
$this->dao = $dao;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -53,9 +53,11 @@ class UserBillRepository extends BaseRepository
|
|||
'integral/sys_dec' => '系统减少积分',
|
||||
'integral/sys_inc' => '系统增加积分',
|
||||
'integral/timeout' => '积分过期',
|
||||
'integral/mer_give' => '商户赠送',
|
||||
'mer_integral/deduction' => '积分抵扣',
|
||||
'mer_integral/refund' => '订单退款',
|
||||
'mer_integral/lock' => '下单赠送积分',
|
||||
'mer_integral/mer_give' => '商户赠送',
|
||||
'mer_lock_money/order' => '商户佣金冻结',
|
||||
'now_money/brokerage' => '佣金转入余额',
|
||||
'now_money/pay_product' => '购买商品',
|
||||
|
|
|
|||
|
|
@ -43,10 +43,12 @@ class UserMerchantRepository extends BaseRepository
|
|||
$query = $this->dao->search($where);
|
||||
$count = $query->count();
|
||||
$make = app()->make(UserLabelRepository::class);
|
||||
$integralMake = app()->make(IntegralRepository::class);
|
||||
$list = $query->setOption('field', [])->field('A.uid,A.user_merchant_id,B.avatar,B.nickname,B.user_type,A.last_pay_time,A.first_pay_time,A.label_id,A.create_time,A.last_time,A.pay_num,A.pay_price,B.phone,B.is_svip,B.svip_endtime')
|
||||
->page($page, $limit)->order('A.user_merchant_id DESC')->select()->each(function ($item) use ($where, $make) {
|
||||
->page($page, $limit)->order('A.user_merchant_id DESC')->select()->each(function ($item) use ($where, $make, $integralMake) {
|
||||
$item->label = count($item['label_id']) ? $make->labels($item['label_id'], $where['mer_id']) : [];
|
||||
$item->svip_endtime = date('Y-m-d H:i:s', strtotime("+100 year"));
|
||||
$item->merchant_integral = $integralMake->getMerIntegral((int)$item->uid,(int)$where['mer_id']);
|
||||
return $item;
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
namespace app\controller\api\store\user;
|
||||
|
||||
use app\common\repositories\user\IntegralGiveRecordRepository;
|
||||
use app\common\repositories\user\IntegralRepository;
|
||||
use app\common\repositories\user\UserBillRepository;
|
||||
use app\common\repositories\user\UserMerchantRepository;
|
||||
use app\common\repositories\user\UserRepository;
|
||||
use crmeb\basic\BaseController;
|
||||
use EasyWeChat\Support\Log;
|
||||
use Exception;
|
||||
use think\App;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* Common: 客户管理
|
||||
* Author: wu-hui
|
||||
* Time: 2023/11/09 16:58
|
||||
* Class UserMerchant
|
||||
* @package app\controller\merchant\user
|
||||
*/
|
||||
class UserMerchant extends BaseController{
|
||||
|
||||
/**
|
||||
* @var UserMerchantRepository
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* UserMerchant constructor.
|
||||
* @param App $app
|
||||
* @param UserMerchantRepository $repository
|
||||
*/
|
||||
public function __construct(App $app, UserMerchantRepository $repository)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Common: 列表获取
|
||||
* Author: wu-hui
|
||||
* Time: 2023/11/09 17:04
|
||||
* @param $merId
|
||||
* @return mixed
|
||||
*/
|
||||
public function getList($merId){
|
||||
$where = $this->request->params(['nickname']);
|
||||
$where['mer_id'] = $merId;
|
||||
[$page, $limit] = $this->getPage();
|
||||
|
||||
return app('json')->success($this->repository->getList($where, $page, $limit));
|
||||
}
|
||||
/**
|
||||
* Common: 商户赠送积分(客户积分变更)
|
||||
* Author: wu-hui
|
||||
* Time: 2023/11/10 11:28
|
||||
* @param $merId
|
||||
* @return mixed
|
||||
*/
|
||||
public function integralChange($merId){
|
||||
$params = $this->request->params(['uid','pm','number','voucher_image']);
|
||||
$params['number'] = abs($params['number']);
|
||||
// 变更操作
|
||||
try {
|
||||
Db::transaction(function () use ($merId, $params) {
|
||||
// 变更记录
|
||||
$giveRecord = app()->make(IntegralGiveRecordRepository::class)->create([
|
||||
'operate_uid' => $this->request->uid(),
|
||||
'uid' => $params['uid'],
|
||||
'mer_id' => $merId,
|
||||
'number' => $params['number'],
|
||||
'voucher_image' => $params['voucher_image'],
|
||||
]);
|
||||
// 总积分到账 & 记录总平台积分变更日志
|
||||
app()->make(UserRepository::class)->incIntegral((int)$params['uid'],$params['number'],'商户赠送积分','mer_give',[
|
||||
'link_id' => $giveRecord->record_id,
|
||||
'number' => $params['number'],
|
||||
'mark' => '商户赠送积分' . $params['number']
|
||||
]);
|
||||
// 商户积分变更
|
||||
app()->make(IntegralRepository::class)->changeIntegral((int)$params['uid'],(int)$merId,$params['number']);
|
||||
// 记录商户端积分变更日志
|
||||
$user = app()->make(UserRepository::class)->get($params['uid']);
|
||||
app()->make(UserBillRepository::class)->create([
|
||||
'uid' => $params['uid'],
|
||||
'link_id' => $giveRecord->record_id,
|
||||
'pm' => $params['pm'],
|
||||
'title' => '商户赠送积分',
|
||||
'category' => 'mer_integral',
|
||||
'type' => 'mer_give',
|
||||
'number' => $params['number'],
|
||||
'balance' => $user->integral,
|
||||
'mark' => '商户赠送积分'.$params['number'],
|
||||
'mer_id' => $merId,
|
||||
'status' => 1
|
||||
]);
|
||||
});
|
||||
|
||||
return app('json')->success('操作成功');
|
||||
} catch (\Throwable $e) {
|
||||
return app('json')->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -110,7 +110,23 @@ class StoreService extends BaseController
|
|||
*/
|
||||
public function checkParams(StoreServiceValidate $validate, $isUpdate = false)
|
||||
{
|
||||
$data = $this->request->params([['uid', []], 'nickname', 'account', 'pwd', 'confirm_pwd', 'is_open', 'status', 'customer', 'is_verify', 'is_goods', 'notify', 'avatar', 'phone', ['sort', 0]]);
|
||||
$data = $this->request->params([
|
||||
['uid',[]],
|
||||
'nickname',
|
||||
'account',
|
||||
'pwd',
|
||||
'confirm_pwd',
|
||||
'is_open',
|
||||
'status',
|
||||
'customer',
|
||||
'is_verify',
|
||||
'is_goods',
|
||||
'is_user',
|
||||
'notify',
|
||||
'avatar',
|
||||
'phone',
|
||||
['sort',0]
|
||||
]);
|
||||
if ($isUpdate) {
|
||||
$validate->update();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,16 @@ Route::group('api/', function () {
|
|||
Route::post('mark/:merId/:uid', 'api.store.service.Service/mark');
|
||||
});
|
||||
|
||||
// 客户管理
|
||||
Route::group('custom', function () {
|
||||
Route::get('list/:merId', 'api.store.user.UserMerchant/getList');
|
||||
Route::post('integral_change/:merId', 'api.store.user.UserMerchant/integralChange');
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//订单
|
||||
Route::group('order', function () {
|
||||
Route::post('check', '/checkOrder');
|
||||
|
|
|
|||
Loading…
Reference in New Issue