更新UserShip模型与相关控制器
This commit is contained in:
parent
61f7ce9332
commit
ed983e0971
95
app/admin/controller/user_ship/UserShipController .php
Normal file
95
app/admin/controller/user_ship/UserShipController .php
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\controller\user_ship;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\controller\BaseAdminController;
|
||||||
|
use app\admin\lists\user_ship\UserShipLists;
|
||||||
|
use app\admin\logic\user_ship\UserShipLogic;
|
||||||
|
use app\admin\validate\user_ship\UserShipValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员类型控制器
|
||||||
|
* Class UserShipController
|
||||||
|
* @package app\admin\controller\user_ship
|
||||||
|
*/
|
||||||
|
class UserShipController extends BaseAdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取会员类型列表
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/06/29 14:18
|
||||||
|
*/
|
||||||
|
public function lists()
|
||||||
|
{
|
||||||
|
return $this->dataLists(new UserShipLists());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加会员类型
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/06/29 14:18
|
||||||
|
*/
|
||||||
|
public function add()
|
||||||
|
{
|
||||||
|
$params = (new UserShipValidate())->post()->goCheck('add');
|
||||||
|
$result = UserShipLogic::add($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('添加成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(UserShipLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑会员类型
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/06/29 14:18
|
||||||
|
*/
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
$params = (new UserShipValidate())->post()->goCheck('edit');
|
||||||
|
$result = UserShipLogic::edit($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('编辑成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(UserShipLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除会员类型
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/06/29 14:18
|
||||||
|
*/
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
$params = (new UserShipValidate())->post()->goCheck('delete');
|
||||||
|
UserShipLogic::delete($params);
|
||||||
|
return $this->success('删除成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取会员类型详情
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/06/29 14:18
|
||||||
|
*/
|
||||||
|
public function detail()
|
||||||
|
{
|
||||||
|
$params = (new UserShipValidate())->goCheck('detail');
|
||||||
|
$result = UserShipLogic::detail($params);
|
||||||
|
return $this->data($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -6,7 +6,7 @@ namespace app\admin\lists\user_label;
|
|||||||
use app\admin\lists\BaseAdminDataLists;
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
use app\common\model\user_label\UserLabel;
|
use app\common\model\user_label\UserLabel;
|
||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
use app\common\model\user\UserShip;
|
use app\common\model\user_ship\UserShip;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户标签列表
|
* 用户标签列表
|
||||||
|
@ -48,9 +48,15 @@ class UserProductStorageLists extends BaseAdminDataLists implements ListsSearchI
|
|||||||
$status=$this->request->get('status',1);
|
$status=$this->request->get('status',1);
|
||||||
if($status==1){
|
if($status==1){
|
||||||
$this->searchWhere[]=['status','=',1];//只显示正常状态的记录,不显示已出库完的记录
|
$this->searchWhere[]=['status','=',1];//只显示正常状态的记录,不显示已出库完的记录
|
||||||
|
$field='id,uid,oid,product_id,sum(nums) nums,status,create_time';
|
||||||
|
$group='product_id';
|
||||||
|
}else{
|
||||||
|
$field='id,uid,oid,product_id,nums,status,create_time';
|
||||||
|
$group=null;
|
||||||
}
|
}
|
||||||
return UserProductStorage::where($this->searchWhere)
|
return UserProductStorage::where($this->searchWhere)
|
||||||
->field(['id', 'uid', 'oid', 'product_id', 'nums', 'status','create_time'])
|
->field($field)
|
||||||
|
->group($group)
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()->each(function($item){
|
->select()->each(function($item){
|
||||||
|
65
app/admin/lists/user_ship/UserShipLists.php
Normal file
65
app/admin/lists/user_ship/UserShipLists.php
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\lists\user_ship;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\model\user_ship\UserShip;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员类型列表
|
||||||
|
* Class UserShipLists
|
||||||
|
* @package app\admin\listsuser_ship
|
||||||
|
*/
|
||||||
|
class UserShipLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/06/29 14:18
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'=' => ['title'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取会员类型列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/06/29 14:18
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
return UserShip::where($this->searchWhere)
|
||||||
|
->field(['id', 'title', 'discount', 'limit', 'sort'])
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['id' => 'desc'])
|
||||||
|
->select()
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取会员类型数量
|
||||||
|
* @return int
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/06/29 14:18
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return UserShip::where($this->searchWhere)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
98
app/admin/logic/user_ship/UserShipLogic.php
Normal file
98
app/admin/logic/user_ship/UserShipLogic.php
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\logic\user_ship;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\user_ship\UserShip;
|
||||||
|
use app\common\logic\BaseLogic;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员类型逻辑
|
||||||
|
* Class UserShipLogic
|
||||||
|
* @package app\admin\logic\user_ship
|
||||||
|
*/
|
||||||
|
class UserShipLogic extends BaseLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加会员类型
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/06/29 14:18
|
||||||
|
*/
|
||||||
|
public static function add(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
UserShip::create([
|
||||||
|
'title' => $params['title'],
|
||||||
|
'limit' => $params['limit'],
|
||||||
|
'sort' => $params['sort']
|
||||||
|
]);
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑会员类型
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/06/29 14:18
|
||||||
|
*/
|
||||||
|
public static function edit(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
UserShip::where('id', $params['id'])->update([
|
||||||
|
'title' => $params['title'],
|
||||||
|
'limit' => $params['limit'],
|
||||||
|
'sort' => $params['sort']
|
||||||
|
]);
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除会员类型
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/06/29 14:18
|
||||||
|
*/
|
||||||
|
public static function delete(array $params): bool
|
||||||
|
{
|
||||||
|
return UserShip::destroy($params['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取会员类型详情
|
||||||
|
* @param $params
|
||||||
|
* @return array
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/06/29 14:18
|
||||||
|
*/
|
||||||
|
public static function detail($params): array
|
||||||
|
{
|
||||||
|
return UserShip::findOrEmpty($params['id'])->toArray();
|
||||||
|
}
|
||||||
|
}
|
88
app/admin/validate/user_ship/UserShipValidate.php
Normal file
88
app/admin/validate/user_ship/UserShipValidate.php
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\validate\user_ship;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\validate\BaseValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员类型验证器
|
||||||
|
* Class UserShipValidate
|
||||||
|
* @package app\admin\validate\user_ship
|
||||||
|
*/
|
||||||
|
class UserShipValidate extends BaseValidate
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置校验规则
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $rule = [
|
||||||
|
'id' => 'require',
|
||||||
|
'title' => 'require',
|
||||||
|
'limit' => 'require',
|
||||||
|
'sort' => 'require',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数描述
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $field = [
|
||||||
|
'id' => 'id',
|
||||||
|
'title' => '会员名称',
|
||||||
|
'limit' => '充值金额',
|
||||||
|
'sort' => '排序倒序',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加场景
|
||||||
|
* @return UserShipValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/06/29 14:18
|
||||||
|
*/
|
||||||
|
public function sceneAdd()
|
||||||
|
{
|
||||||
|
return $this->only(['title','limit','sort']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑场景
|
||||||
|
* @return UserShipValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/06/29 14:18
|
||||||
|
*/
|
||||||
|
public function sceneEdit()
|
||||||
|
{
|
||||||
|
return $this->only(['id','title','limit','sort']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除场景
|
||||||
|
* @return UserShipValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/06/29 14:18
|
||||||
|
*/
|
||||||
|
public function sceneDelete()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 详情场景
|
||||||
|
* @return UserShipValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/06/29 14:18
|
||||||
|
*/
|
||||||
|
public function sceneDetail()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -27,7 +27,7 @@ use app\common\model\system_store\SystemStore;
|
|||||||
use app\common\model\user\User;
|
use app\common\model\user\User;
|
||||||
use app\common\model\user\UserAddress;
|
use app\common\model\user\UserAddress;
|
||||||
use app\common\model\user\UserRecharge;
|
use app\common\model\user\UserRecharge;
|
||||||
use app\common\model\user\UserShip;
|
use app\common\model\user_ship\UserShip;
|
||||||
use app\common\model\user_sign\UserSign;
|
use app\common\model\user_sign\UserSign;
|
||||||
use app\common\model\vip_flow\VipFlow;
|
use app\common\model\vip_flow\VipFlow;
|
||||||
use app\common\service\pay\PayService;
|
use app\common\service\pay\PayService;
|
||||||
|
@ -25,7 +25,7 @@ use app\common\model\system_store\SystemStore;
|
|||||||
use app\common\model\system_store\SystemStoreStaff;
|
use app\common\model\system_store\SystemStoreStaff;
|
||||||
use app\common\model\user\User;
|
use app\common\model\user\User;
|
||||||
use app\common\model\user\UserAddress;
|
use app\common\model\user\UserAddress;
|
||||||
use app\common\model\user\UserShip;
|
use app\common\model\user_ship\UserShip;
|
||||||
use app\common\model\user_sign\UserSign;
|
use app\common\model\user_sign\UserSign;
|
||||||
use app\common\model\user_spread_log\UserSpreadLog;
|
use app\common\model\user_spread_log\UserSpreadLog;
|
||||||
use Picqer\Barcode\BarcodeGeneratorJPG;
|
use Picqer\Barcode\BarcodeGeneratorJPG;
|
||||||
|
@ -16,7 +16,7 @@ use app\common\{logic\BaseLogic,
|
|||||||
model\user\User,
|
model\user\User,
|
||||||
model\user\UserAuth,
|
model\user\UserAuth,
|
||||||
model\user\UserRecharge,
|
model\user\UserRecharge,
|
||||||
model\user\UserShip,
|
model\user_ship\UserShip,
|
||||||
model\user_sign\UserSign,
|
model\user_sign\UserSign,
|
||||||
model\vip_flow\VipFlow,
|
model\vip_flow\VipFlow,
|
||||||
service\SmsService,
|
service\SmsService,
|
||||||
|
@ -5,7 +5,7 @@ namespace app\common\lists\user;
|
|||||||
|
|
||||||
|
|
||||||
use app\admin\lists\BaseAdminDataLists;
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
use app\common\model\user\UserShip;
|
use app\common\model\user_ship\UserShip;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员类型
|
* 会员类型
|
||||||
|
@ -23,7 +23,7 @@ use app\common\model\system_store\SystemStore;
|
|||||||
use app\common\model\user\User;
|
use app\common\model\user\User;
|
||||||
use app\common\model\user\UserAddress;
|
use app\common\model\user\UserAddress;
|
||||||
use app\common\model\user\UserRecharge;
|
use app\common\model\user\UserRecharge;
|
||||||
use app\common\model\user\UserShip;
|
use app\common\model\user_ship\UserShip;
|
||||||
use app\common\model\user_sign\UserSign;
|
use app\common\model\user_sign\UserSign;
|
||||||
use app\common\service\Curl;
|
use app\common\service\Curl;
|
||||||
use app\common\service\PushService;
|
use app\common\service\PushService;
|
||||||
|
@ -23,7 +23,7 @@ use app\common\model\system_store\SystemStore;
|
|||||||
use app\common\model\user\User;
|
use app\common\model\user\User;
|
||||||
use app\common\model\user\UserAddress;
|
use app\common\model\user\UserAddress;
|
||||||
use app\common\model\user\UserRecharge;
|
use app\common\model\user\UserRecharge;
|
||||||
use app\common\model\user\UserShip;
|
use app\common\model\user_ship\UserShip;
|
||||||
use app\common\model\user_sign\UserSign;
|
use app\common\model\user_sign\UserSign;
|
||||||
use app\common\model\vip_flow\VipFlow;
|
use app\common\model\vip_flow\VipFlow;
|
||||||
use app\common\service\Curl;
|
use app\common\service\Curl;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace app\common\model\user;
|
namespace app\common\model\user_ship;
|
||||||
|
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
use think\model\concern\SoftDelete;
|
use think\model\concern\SoftDelete;
|
@ -8,7 +8,7 @@ use app\common\model\store_finance_flow\StoreFinanceFlow;
|
|||||||
use app\common\model\user_sign\UserSign;
|
use app\common\model\user_sign\UserSign;
|
||||||
use app\store\lists\BaseAdminDataLists;
|
use app\store\lists\BaseAdminDataLists;
|
||||||
use app\common\model\user\User;
|
use app\common\model\user\User;
|
||||||
use app\common\model\user\UserShip;
|
use app\common\model\user_ship\UserShip;
|
||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
|
||||||
class UserLists extends BaseAdminDataLists implements ListsSearchInterface
|
class UserLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
Loading…
x
Reference in New Issue
Block a user