Commit e9a00277 authored by 龚双喜's avatar 龚双喜

Merge branch 'dev' of git.ruanyiit.com:liuxiaomin/loveisland into dev

parents 035f6571 ce4f5d93
<?php
namespace addons\shopro\controller\user;
use addons\shopro\controller\Common;
use app\admin\model\shopro\AiTryon as AiTryOnModel;
use think\Db;
class AiTryon extends Common
{
protected $noNeedLogin = [];
protected $noNeedRight = ['*'];
public function _initialize()
{
parent::_initialize();
// \think\Lang::load(APP_PATH . 'api/lang/zh-cn/user.php'); // 加载语言包
}
/**
* 保存至我的试戴
*/
public function saveMyTryon()
{
if (!$this->request->isPost()) {
$this->error('');
}
$user = auth_user();
$params = $this->request->only([
'url', 'goods_id', 'goods_title', 'goods_sku_id', 'goods_sku_name', 'goods_sku_image'
]);
$params['user_id'] = $user->id;
$this->svalidate($params, ".add");
Db::transaction(function () use ($params) {
$userAddress = new AiTryOnModel();
$userAddress->save($params);
});
$this->success('保存成功' );
}
/**
* 我的试戴
*/
public function myTryon()
{
$user = auth_user();
// 查询我的试戴列表
$data = AiTryOnModel::where('user_id', $user->id)
->order('id', 'desc')
->paginate(request()->param('list_rows', 10))
->toArray();
$this->success('我的试戴', $data);
}
}
......@@ -9,8 +9,8 @@ use app\admin\model\shopro\user\User as UserModel;
use app\admin\model\shopro\user\Coupon as UserCouponModel;
use app\admin\model\shopro\order\Order as OrderModel;
use app\admin\model\shopro\order\Aftersale as AftersaleModel;
use app\admin\model\shopro\AiTryon as AiTryOnModel;
use app\admin\model\shopro\ThirdOauth;
use think\Db;
class User extends Common
{
......@@ -48,22 +48,6 @@ class User extends Common
}
/**
* 我的试戴
*/
public function myTryon()
{
$user = auth_user();
// 查询我的试戴列表
$data = AiTryOnModel::where('user_id', $user->id)
->order('id', 'desc')
->paginate(request()->param('list_rows', 10))
->toArray();
$this->success('我的试戴', $data);
}
/**
* 第三方授权信息
*/
public function thirdOauth()
......
<?php
namespace addons\shopro\validate\user;
use think\Validate;
class AiTryon extends Validate
{
/**
* 验证规则
*/
protected $rule = [
'url' => 'require|length:0,255',
'goods_title' => 'require|length:0,255',
'goods_sku_name' => 'require|length:0,255',
'goods_sku_image' => 'require|length:0,255',
];
/**
* 提示消息
*/
protected $message = [
'url.require' => 'AI结果缺失',
'url.length' => 'AI结果长度必须在 0-255 位',
'goods_title.require' => '商品名称缺失',
'goods_title.length' => '商品名称长度必须在 0-255 位',
'goods_sku_name.require' => '商品型号名称缺失',
'goods_sku_name.length' => '商品型号名称长度必须在 0-255 位',
'goods_sku_image.require' => '商品型号图片缺失',
'goods_sku_image.length' => '商品型号图片长度必须在 0-255 位'
];
/**
* 验证场景
*/
protected $scene = [
'add' => ['url', 'goods_id', 'goods_title', 'goods_sku_id', 'goods_sku_name', 'goods_sku_image'],
'edit' => [],
];
}
......@@ -24,12 +24,12 @@ class AiTryon extends Model
'url',
'user_id',
'goods_id',
'goods_sku_id',
'goods_title',
'goods_image',
'goods_sku_id',
'goods_sku_image',
'goods_sku_name'
];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment