作者 何书鹏
1 个管道 的构建 通过 耗费 2 秒

完善接口

... ... @@ -22,7 +22,7 @@ class StyleTemplate extends Backend
{
parent::_initialize();
$this->model = new \app\admin\model\StyleTemplate;
$this->view->assign("typeList", $this->model->getTypeList());
}
public function import()
... ... @@ -35,44 +35,37 @@ class StyleTemplate extends Backend
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
/**
* 查看
*/
public function index()
{
//当前是否为关联查询
$this->relationSearch = false;
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax())
{
$this->request->filter(['strip_tags']);
if ($this->request->isAjax()) {
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField'))
{
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$total = $this->model
->where($where)
->order($sort, $order)
->count();
$search = $this->request->request("search");
$type = $this->request->request("type");
$where = [];
if(!empty($search)){
$where['name'] = ['like','%'.$search.'%'];
}
if(!empty($type) && $type != 'all'){
$where['type'] = $type;
}
$list = $this->model
->where($where)
->order($sort, $order)
->limit($offset, $limit)
->select();
foreach ($list as $row) {
$row->visible(['id','name','updatetime']);
$row->visible(['id','name','type','updatetime']);
}
$list = collection($list)->toArray();
$result = array("total" => $total, "rows" => $list);
$result = array("total" => count($list), "rows" => $list);
return json($result);
}
... ...
... ... @@ -29,12 +29,18 @@ class StyleTemplate extends Model
];
/**
* 读取分类类型
* @return array
*/
public function getTypeList()
{
$typeList = config('site.templatetype');
foreach ($typeList as $k => &$v) {
$v = __($v);
}
return $typeList;
}
}
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label for="c-type" class="control-label col-xs-12 col-sm-2">{:__('模板类型')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
{foreach name="typeList" item="vo"}
<option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
<div class="col-xs-12 col-sm-8">
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label for="c-type" class="control-label col-xs-12 col-sm-2">{:__('模板类型')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
{foreach name="typeList" item="vo"}
<option value="{$key}" {in name="key" value="$row.type"}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
<div class="col-xs-12 col-sm-8">
... ...
<div class="panel panel-default panel-intro">
{:build_heading()}
<ul class="nav nav-tabs">
<li class="active"><a href="#all" data-toggle="tab">{:__('All')}</a></li>
{foreach name="typeList" item="vo"}
<li><a href="#{$key}" data-toggle="tab">{$vo}</a></li>
{/foreach}
</ul>
<div class="panel-body">
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade active in" id="one">
... ...
... ... @@ -196,8 +196,8 @@ class Cart extends Api
$this->success(__('成功'),$order);
}
// 生成订单信息错误
if ($order->hasError()) {
$this->error($order->getError());
if ($this->model->getError()) {
$this->error($this->model->getError());
}
// 创建订单
$model = new \app\common\model\Order;
... ...
... ... @@ -13,7 +13,7 @@ use think\Config;
*/
class Common extends Api
{
protected $noNeedLogin = ['init'];
protected $noNeedLogin = ['init','upload'];
protected $noNeedRight = '*';
/**
... ... @@ -132,7 +132,8 @@ class Common extends Api
$attachment->save();
\think\Hook::listen("upload_after", $attachment);
$this->success(__('Upload successful'), [
'url' => $uploadDir . $splInfo->getSaveName()
'url' => $uploadDir . $splInfo->getSaveName(),
'full_url' => cdnurl($uploadDir . $splInfo->getSaveName(),true)
]);
} else {
// 上传失败获取错误信息
... ...
... ... @@ -143,4 +143,26 @@ class Order extends Api
}
$this->error($order->getError());
}
/**
* 我的订单-申请退款
* @ApiMethod (GET)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="order_id", type="integer", required=true, description="订单ID")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
})
*/
public function refundView($order_id)
{
if(!$order = $this->model->getUserOrderDetail($order_id, $this->user['id'])){
$this->error($this->model->getError());
}
$this->success(__('成功'),$order);
$this->error($order->getError());
}
}
... ...
... ... @@ -39,7 +39,13 @@ class User extends Api
{
// 当前用户信息
$user = $this->auth->getUser();
return $this->success('成功',compact('user'));
$coupon_count = \app\common\model\UserCoupon::alias('uc')
->join('coupon c','c.id = uc.coupon_id')
->where('uc.user_id',$user['id'])
->where('uc.status','1')
->where('c.expiretime','>',time())
->count();
return $this->success('成功',compact('user','coupon_count'));
}
/**
... ... @@ -193,6 +199,7 @@ class User extends Api
* @ApiParams (name="phone", type="string", required=true, description="手机号码")
* @ApiParams (name="area", type="string", required=true, description="所在地区", sample="广东省,广州市,海珠区")
* @ApiParams (name="detail", type="string", description="详细地址")
* @ApiParams (name="isdefault", type="string", description="是否默认:0=否,1=是")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
... ... @@ -205,7 +212,11 @@ class User extends Api
{
$user = $this->auth->getUser();
$post = $this->request->request();
if (UserAddress::add($user, $post)) {
empty($post['name']) && $this->error(__('请填写收货人'));
empty($post['phone']) && $this->error(__('请填写手机号码'));
empty($post['area']) && $this->error(__('请选择所在地区'));
empty($post['detail']) && $this->error(__('请填写详细地址'));
if ((new UserAddress)->add($user, $post)) {
$this->success(__('添加成功'));
}
$this->error(__('添加失败'));
... ... @@ -215,7 +226,7 @@ class User extends Api
* 我的地址-详情
* @ApiMethod (GET)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="address_id", type="integer", required=true, description="地址ID")
* @ApiParams (name="user_address_id", type="integer", required=true, description="地址ID")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
... ... @@ -227,8 +238,8 @@ class User extends Api
public function addressDetail()
{
$user = $this->auth->getUser();
$address_id = $this->request->request('address_id');
$detail = UserAddress::detail($user['id'],$address_id);
$user_address_id = $this->request->request('user_address_id');
$detail = UserAddress::detail($user['id'],$user_address_id);
$area = array_values($detail['area']);
$this->success(__('成功'),compact('detail', 'area'));
}
... ... @@ -237,11 +248,12 @@ class User extends Api
* 我的地址-编辑
* @ApiMethod (POST)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="address_id", type="integer", required=true, description="地址ID")
* @ApiParams (name="user_address_id", type="integer", required=true, description="地址ID")
* @ApiParams (name="name", type="string", required=true, description="收货人")
* @ApiParams (name="phone", type="string", required=true, description="手机号码")
* @ApiParams (name="area", type="object", required=true, description="所在地区", sample="{'user_id':'int','user_name':'string','profile':{'email':'string','age':'integer'}}")
* @ApiParams (name="detail", type="string", description="详细地址")
* @ApiParams (name="isdefault", type="string", description="是否默认:0=否,1=是")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
... ... @@ -253,12 +265,15 @@ class User extends Api
public function addressEdit()
{
$user = $this->auth->getUser();
$post['address_id'] = $this->request->post('address_id');
$post['name'] = $this->request->post('name');
$post['phone'] = $this->request->post('phone');
$post['area'] = $this->request->post('area');
$post['detail'] = $this->request->post('detail');
$model = UserAddress::detail($user['id'], $post['address_id']);
$post = $this->request->request();
$model = UserAddress::detail($user['id'], $post['user_address_id']);
if(empty($model)){
$this->error(__('地址不存在'));
}
empty($post['name']) && $this->error(__('请填写收货人'));
empty($post['phone']) && $this->error(__('请填写手机号码'));
empty($post['area']) && $this->error(__('请选择所在地区'));
empty($post['detail']) && $this->error(__('请填写详细地址'));
if ($model->edit($post)) {
$this->success(__('更新成功'));
}
... ... @@ -269,7 +284,7 @@ class User extends Api
* 我的地址-删除
* @ApiMethod (GET)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="address_id", type="integer", required=true, description="地址ID")
* @ApiParams (name="user_address_id", type="integer", required=true, description="地址ID")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
... ... @@ -281,8 +296,8 @@ class User extends Api
public function addressDelete()
{
$user = $this->auth->getUser();
$address_id = $this->request->request('address_id');
$model = UserAddress::detail($user['id'], $address_id);
$user_address_id = $this->request->request('user_address_id');
$model = UserAddress::detail($user['id'], $user_address_id);
if ($model->remove($user)) {
$this->success(__('删除成功'));
}
... ... @@ -290,6 +305,30 @@ class User extends Api
}
/**
* 我的地址-设为默认
* @ApiMethod (GET)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="user_address_id", type="integer", required=true, description="尺寸ID")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
})
*/
public function addressDefault()
{
$user = $this->auth->getUser();
$user_size_id = $this->request->request('user_size_id');
$model = UserAddress::detail($user['id'], $user_size_id);
if ($model->setDefault()) {
$this->success(__('设置成功'));
}
$this->error(__('设置失败'));
}
/**
* 我的尺寸-列表
* @ApiMethod (GET)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
... ... @@ -309,6 +348,59 @@ class User extends Api
}
/**
* 我的尺寸-身体信息
* @ApiMethod (GET)
* @ApiParams (name="gender", type="string", required=true, description="性别:1=男,2=女")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
})
*/
public function bodyInfo()
{
$gender = $this->request->request('gender','1');
$list = \app\common\model\Style::styleList($gender);
$this->success(__('成功'),compact('list'));
}
/**
* 我的尺寸-身材特征
* @ApiMethod (GET)
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
})
*/
public function bodyFeatures()
{
$list = \app\common\model\Style::styleList(3);
$this->success(__('成功'),compact('list'));
}
/**
* 我的尺寸-全身照或半身照
* @ApiMethod (GET)
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
})
*/
public function bodyImage()
{
$list = \app\common\model\Style::styleList(4);
$this->success(__('成功'),compact('list'));
}
/**
* @ApiTitle (我的尺寸-添加)
* @ApiMethod (POST)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
... ... @@ -322,7 +414,7 @@ class User extends Api
* @ApiParams (name="shoulder_width", type="integer", description="肩宽(厘米)")
* @ApiParams (name="gender", type="string", required=true, description="性别:1=男,2=女")
* @ApiParams (name="body_info", type="object", required=true, description="身体信息")
* @ApiParams (name="body_features", type="set", description="身体特征:1=脖子粗,2=手臂特别长,3=肩膀特别宽,多个值用英文逗号分隔")
* @ApiParams (name="body_features", type="string", description="身体特征,多个值用英文逗号分隔")
* @ApiParams (name="remark", type="string", description="备注")
* @ApiParams (name="body_images", type="file", description="身材照片,多文件")
* @ApiParams (name="isdefault", type="string", description="是否默认:0=否,1=是")
... ... @@ -338,12 +430,12 @@ class User extends Api
{
$user = $this->auth->getUser();
$post = $this->request->request();
!empty($post['name']) && $this->error(__('请填写尺寸名称'));
!empty($post['height']) && $this->error(__('请填写身高'));
!empty($post['weight']) && $this->error(__('请填写体重'));
!empty($post['gender']) && $this->error(__('请选择性别'));
!empty($post['body_info']) && $this->error(__('请选择身体信息'));
if (UserSize::add($user, $post)) {
empty($post['name']) && $this->error(__('请填写尺寸名称'));
empty($post['height']) && $this->error(__('请填写身高'));
empty($post['weight']) && $this->error(__('请填写体重'));
empty($post['gender']) && $this->error(__('请选择性别'));
empty($post['body_info']) && $this->error(__('请选择身体信息'));
if ((new UserSize)->add($user, $post)) {
$this->success(__('添加成功'));
}
$this->error(__('添加失败'));
... ... @@ -353,7 +445,7 @@ class User extends Api
* 我的尺寸-详情
* @ApiMethod (GET)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="size_id", type="integer", required=true, description="尺寸ID")
* @ApiParams (name="user_size_id", type="integer", required=true, description="尺寸ID")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
... ... @@ -365,8 +457,8 @@ class User extends Api
public function sizeDetail()
{
$user = $this->auth->getUser();
$size_id = $this->request->request('size_id');
$detail = UserSize::detail($user['id'],$size_id);
$user_size_id = $this->request->request('user_size_id');
$detail = UserSize::detail($user['id'],$user_size_id);
$this->success(__('成功'),compact('detail'));
}
... ... @@ -374,7 +466,7 @@ class User extends Api
* 我的尺寸-编辑
* @ApiMethod (POST)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="size_id", type="integer", required=true, description="尺寸ID")
* @ApiParams (name="user_size_id", type="integer", required=true, description="尺寸ID")
* @ApiParams (name="name", type="string", required=true, description="尺寸名称")
* @ApiParams (name="height", type="integer", required=true, description="身高(厘米)")
* @ApiParams (name="weight", type="integer", required=true, description="体重(公斤)")
... ... @@ -385,7 +477,7 @@ class User extends Api
* @ApiParams (name="shoulder_width", type="integer", description="肩宽(厘米)")
* @ApiParams (name="gender", type="string", required=true, description="性别:1=男,2=女")
* @ApiParams (name="body_info", type="object", required=true, description="身体信息")
* @ApiParams (name="body_features", type="set", description="身体特征:1=脖子粗,2=手臂特别长,3=肩膀特别宽,多个值用英文逗号分隔")
* @ApiParams (name="body_features", type="string", description="身体特征,多个值用英文逗号分隔")
* @ApiParams (name="remark", type="string", description="备注")
* @ApiParams (name="body_images", type="file", description="身材照片,多文件")
* @ApiParams (name="isdefault", type="string", description="是否默认:0=否,1=是")
... ... @@ -401,15 +493,15 @@ class User extends Api
{
$user = $this->auth->getUser();
$post = $this->request->request();
$model = UserSize::detail($user['id'], $post['size_id']);
$model = UserSize::detail($user['id'], $post['user_size_id']);
if(empty($model)){
$this->error(__('尺寸信息不存在'));
}
!empty($post['name']) && $this->error(__('请填写尺寸名称'));
!empty($post['height']) && $this->error(__('请填写身高'));
!empty($post['weight']) && $this->error(__('请填写体重'));
!empty($post['gender']) && $this->error(__('请选择性别'));
!empty($post['body_info']) && $this->error(__('请选择身体信息'));
empty($post['name']) && $this->error(__('请填写尺寸名称'));
empty($post['height']) && $this->error(__('请填写身高'));
empty($post['weight']) && $this->error(__('请填写体重'));
empty($post['gender']) && $this->error(__('请选择性别'));
empty($post['body_info']) && $this->error(__('请选择身体信息'));
if ($model->edit($post)) {
$this->success(__('更新成功'));
}
... ... @@ -420,7 +512,7 @@ class User extends Api
* 我的尺寸-删除
* @ApiMethod (GET)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="size_id", type="integer", required=true, description="尺寸ID")
* @ApiParams (name="user_size_id", type="integer", required=true, description="尺寸ID")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
... ... @@ -432,8 +524,8 @@ class User extends Api
public function sizeDelete()
{
$user = $this->auth->getUser();
$size_id = $this->request->request('size_id');
$model = UserSize::detail($user['id'], $size_id);
$user_size_id = $this->request->request('user_size_id');
$model = UserSize::detail($user['id'], $user_size_id);
if ($model->remove($user)) {
$this->success(__('删除成功'));
}
... ... @@ -441,8 +533,10 @@ class User extends Api
}
/**
* 我的尺寸-量体教程
* 我的尺寸-设为默认
* @ApiMethod (GET)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="user_size_id", type="integer", required=true, description="尺寸ID")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
... ... @@ -451,16 +545,20 @@ class User extends Api
'msg':'返回成功'
})
*/
public function measure()
public function sizeDefault()
{
$measure = config('site.measure');
$this->success(__('成功'),compact('measure'));
$user = $this->auth->getUser();
$user_size_id = $this->request->request('user_size_id');
$model = UserSize::detail($user['id'], $user_size_id);
if ($model->setDefault()) {
$this->success(__('设置成功'));
}
$this->error(__('设置失败'));
}
/**
* 身体信息
* 我的尺寸-量体教程
* @ApiMethod (GET)
* @ApiParams (name="gender", type="string", required=true, description="性别:1=男,2=女")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
... ... @@ -469,10 +567,9 @@ class User extends Api
'msg':'返回成功'
})
*/
public function bodyInfo()
public function measure()
{
$gender = $this->request->request('gender','1');
$list = \app\common\model\Spec::bodyInfo($gender);
$this->success(__('成功'),compact('list'));
$measure = str_replace('src="/uploads/', 'src="'.config('upload.cdnurl').'/uploads/', config('site.measure'));
$this->success(__('成功'),compact('measure'));
}
}
... ...
... ... @@ -67,7 +67,7 @@ class Cart extends Model
*/
public function add($user,$data)
{
$goods = Goods::get($data['goods_id']);
$goods = Goods::get($data['goods_id'],['spec_rel.spec']);
if(empty($goods)){
$this->setError(__('商品不存在'));
return false;
... ... @@ -102,11 +102,11 @@ class Cart extends Model
// 非定制
$spec_sku_id = 0;
if($goods['spec_type'] == '2'){
if(empty($data['goods_sku_id'])){
if(empty($data['spec_sku_id'])){
$this->setError(__('请选择规格'));
return false;
}
$spec_sku_id = $data['goods_sku_id'];
$spec_sku_id = $data['spec_sku_id'];
}
$goods_sku = $goods->getGoodsSku($spec_sku_id);
$data['make_type'] = '0';
... ... @@ -155,14 +155,14 @@ class Cart extends Model
$cart_list = [];
foreach ($list as $key => $cart) {
// 判断商品不存在则自动删除
$goods = $cart['goods'];
$goods = Goods::get($cart['goods_id'],['spec_rel.spec']);
if (!$goods) {
$this->where('goods_id',$cart['goods_id'])->delete();
continue;
}
// 商品sku不存在则自动删除
if (!$cart['goods_sku'] = $goods->getGoodsSku($cart['goods_sku_id'])) {
$this->where(['goods_id'=>$cart['goods_id'],'goods_sku_id'=>$cart['goods_sku_id']])->delete();
if (!$cart['goods_sku'] = $goods->getGoodsSku($cart['spec_sku_id'])) {
$this->where(['goods_id'=>$cart['goods_id'],'spec_sku_id'=>$cart['spec_sku_id']])->delete();
continue;
}
// 判断商品是否下架
... ...
... ... @@ -135,7 +135,7 @@ class Goods extends Model
*/
public function getGoodsSku($goods_sku_id)
{
$goodsSkuData = array_column($this['spec']->toArray(), null, 'spec_sku_id');
$goodsSkuData = array_column(collection($this['spec'])->toArray(), null, 'spec_sku_id');
if (!isset($goodsSkuData[$goods_sku_id])) {
return false;
}
... ... @@ -144,7 +144,7 @@ class Goods extends Model
$goods_sku['goods_attr'] = '';
if ($this['spec_type'] == '2') {
$attrs = explode('_', $goods_sku['spec_sku_id']);
$spec_rel = array_column($this['spec_rel']->toArray(), null, 'spec_value_id');
$spec_rel = array_column(collection($this['spec_rel'])->toArray(), null, 'id');
foreach ($attrs as $specValueId) {
$goods_sku['goods_attr'] .= $spec_rel[$specValueId]['spec']['spec_name'] . ':'
. $spec_rel[$specValueId]['spec_value_name'] . '; ';
... ...
... ... @@ -11,6 +11,6 @@ class GoodsSpecRel extends Model
*/
public function spec()
{
return $this->blongsTo('spec');
return $this->belongsTo('Spec');
}
}
... ...
... ... @@ -79,11 +79,11 @@ class Order extends Model
'detail' => $order['address']['detail'],
]);
// 用掉优惠券
if($order['user_coupon_id'] > 0){
if($order['coupon']['user_coupon_id'] > 0){
UserCoupon::where('id',$order['user_coupon_id'])->setField('status','2');
}
// 用掉积分
if($order['score'] > 0){
if($order['score']['score'] > 0){
User::score(-$order['score'],$order['user_id'],'订单支付');
}
Db::commit();
... ...
... ... @@ -44,8 +44,9 @@ class UserAddress extends Model
/**
* 新增收货地址
*/
public static function add($user, $data)
public function add($user, $data)
{
empty($data['isdefault']) && $data['isdefault'] = '0';
// 添加收货地址
$area = explode(',', $data['area']);
$province_id = Area::getIdByName($area[0], 1);
... ... @@ -53,16 +54,16 @@ class UserAddress extends Model
$district_id = Area::getIdByName($area[2], 3, $city_id);
// 该地址设为默认,其他地址就设为非默认
if($data['isdefault'] == '1'){
self::where('user_id',$user['id'])->update(['isdefault'=>'0']);
$this->where('user_id',$user['id'])->update(['isdefault'=>'0']);
}
self::create(array_merge([
$this->allowField(true)->save(array_merge([
'user_id' => $user['id'],
'province_id' => $province_id,
'city_id' => $city_id,
'district_id' => $district_id
], $data));
// 没有默认收货地址,就把该收货地址设为默认
!self::get(['user_id'=>$user['id'],'isdefault'=>'1']) && self::update(['id'=>self::getLastInsID(),'isdefault'=>'1']);
!$this->get(['user_id'=>$user['id'],'isdefault'=>'1']) && self::update(['id'=>$this['id'],'isdefault'=>'1']);
return true;
}
... ... @@ -71,6 +72,7 @@ class UserAddress extends Model
*/
public function edit($data)
{
empty($data['isdefault']) && $data['isdefault'] = '0';
// 添加收货地址
$area = explode(',', $data['area']);
$province_id = Area::getIdByName($area[0], 1);
... ... @@ -92,7 +94,9 @@ class UserAddress extends Model
// 查询当前是否为默认地址
if($this['isdefault'] == '1'){
$this->delete();
self::get(['user_id'=>$user['id']])->update(['isdefault'=>'1']);
$address = $this->get(['user_id'=>$user['id']]);
$address->isdefault = "1";
$address->save();
}else{
$this->delete();
}
... ... @@ -100,6 +104,16 @@ class UserAddress extends Model
}
/**
* 设置为默认
*/
public function setDefault()
{
$this->where('user_id',$this['user_id'])->update(['isdefault'=>'0']);
$this->update(['id'=>$this['id'],'isdefault'=>'1']);
return true;
}
/**
* 收货地址详情
*/
public static function detail($user_id, $id)
... ...
... ... @@ -34,30 +34,30 @@ class UserSize extends Model
/**
* 新增尺寸
*/
public static function add($user, $data)
public function add($user, $data)
{
empty($data['isdefault']) && $data['isdefault'] = '0';
// 该尺寸设为默认,其他地址就设为非默认
if($data['isdefault'] == '1'){
self::where('user_id',$user['id'])->update(['isdefault'=>'0']);
}else{
$data['isdefault'] = '0';
$this->where('user_id',$user['id'])->update(['isdefault'=>'0']);
}
self::create(array_merge([
$this->allowField(true)->save(array_merge([
'user_id' => $user['id'],
], $data),true);
], $data));
// 没有默认收货地址,就把该收货地址设为默认
!self::get(['user_id'=>$user['id'],'isdefault'=>'1']) && self::update(['id'=>self::getLastInsID(),'isdefault'=>'1']);
!$this->get(['user_id'=>$user['id'],'isdefault'=>'1']) && $this->update(['id'=>$this['id'],'isdefault'=>'1']);
return true;
}
/**
* 编辑尺寸
*/
public static function edit($data)
public function edit($data)
{
empty($data['isdefault']) && $data['isdefault'] = '0';
// 该地址设为默认,其他地址就设为非默认
if($data['isdefault'] == '1'){
self::where('user_id',$this['user_id'])->update(['isdefault'=>'0']);
$this->where('user_id',$this['user_id'])->update(['isdefault'=>'0']);
}
return $this->allowField(true)
->save($data);
... ... @@ -66,12 +66,14 @@ class UserSize extends Model
/**
* 删除尺寸
*/
public static function remove($user)
public function remove($user)
{
// 查询当前是否为默认地址
if($this['isdefault'] == '1'){
$this->delete();
self::get(['user_id'=>$user['id']])->update(['isdefault'=>'1']);
$size = $this->get(['user_id'=>$user['id']]);
$size->isdefault = '1';
$size->save();
}else{
$this->delete();
}
... ... @@ -79,6 +81,16 @@ class UserSize extends Model
}
/**
* 设置为默认
*/
public function setDefault()
{
$this->where('user_id',$this['user_id'])->update(['isdefault'=>'0']);
$this->update(['id'=>$this['id'],'isdefault'=>'1']);
return true;
}
/**
* 尺寸详情
*/
public static function detail($user_id, $id)
... ...
... ... @@ -16,13 +16,13 @@ return [
// 数据库类型
'type' => Env::get('database.type', 'mysql'),
// 服务器地址
'hostname' => Env::get('database.hostname', '127.0.0.1'),
'hostname' => Env::get('database.hostname', '1f692e5a3458475ea270448f4d3bfde5in01.internal.cn-east-2.mysql.rds.myhuaweicloud.com'),
// 数据库名
'database' => Env::get('database.database', 'silk'),
// 用户名
'username' => Env::get('database.username', 'root'),
'username' => Env::get('database.username', 'db136s1ehvo1yn73'),
// 密码
'password' => Env::get('database.password', 'root'),
'password' => Env::get('database.password', 'cxz307311SJK'),
// 端口
'hostport' => Env::get('database.hostport', ''),
// 连接dsn
... ...
... ... @@ -39,10 +39,15 @@ return array (
'key' => '0',
'sendscore' => '1',
'scoreprice' => '100',
'measure' => '/uploads/20200702/3689359dcdf1146d234930cae4958110.jpg',
'express' =>
array (
0 => '8',
5 => '10',
),
'templatetype' =>
array (
'style' => '定制风格',
'size' => '尺寸信息',
),
'measure' => '<p><img src="/uploads/20200724/124840a14af5e41c8508aac71242fad5.gif" style="width: 499px;"><br></p><p>量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程量体教程</p>',
);
\ No newline at end of file
... ...
... ... @@ -9,7 +9,7 @@ return [
/**
* CDN地址
*/
'cdnurl' => '',
'cdnurl' => 'http://192.168.1.9',
/**
* 文件保存格式
*/
... ...
此 diff 太大无法显示。
... ... @@ -22,10 +22,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
pagination: false,
commonSearch: false,
search: false,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'type', title: __('模板类型'), operate: false, searchList: Config.searchList, formatter: Table.api.formatter.label},
{field: 'name', title: __('Name')},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
//操作栏,默认有编辑、删除或排序按钮,可自定义配置buttons来扩展按钮
... ... @@ -47,7 +51,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
formatter: function (value, row, index) {
var that = $.extend({}, this);
var table = $(that.table).clone(true);
if(row.id == 1 || row.id == 2){
if(row.type == 'size'){
$(table).data("operate-del", null); // 列表页面隐藏 .编辑operate-edit - 删除按钮operate-del
}
that.table = table;
... ... @@ -60,6 +64,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// 为表格绑定事件
Table.api.bindevent(table);
//绑定TAB事件
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
// var options = table.bootstrapTable(tableOptions);
var typeStr = $(this).attr("href").replace('#', '');
var options = table.bootstrapTable('getOptions');
options.pageNumber = 1;
options.queryParams = function (params) {
// params.filter = JSON.stringify({type: typeStr});
params.type = typeStr;
console.log(params);
return params;
};
table.bootstrapTable('refresh', {});
return false;
});
},
add: function () {
Controller.api.bindevent();
... ...