1
This commit is contained in:
parent
b5a3a6666f
commit
70108bfe30
@ -1066,11 +1066,11 @@ class Api extends BaseController
|
|||||||
|
|
||||||
$date = get_params('date') ?? 'today';
|
$date = get_params('date') ?? 'today';
|
||||||
$merId = get_params('mer_id') ??'';
|
$merId = get_params('mer_id') ??'';
|
||||||
|
$www2[] = ['A.uid','in', $arrUid];
|
||||||
$res = Cache::store('file')->remember(self::class . '@product' . $merId . $date, function () use ($merId, $date, $arrUid) {
|
$res = Cache::store('file')->remember(self::class . '@product' . $merId . $date, function () use ($merId, $date, $arrUid,$www2) {
|
||||||
return Db::connect('shop')->table('eb_store_order_product')
|
return Db::connect('shop')->table('eb_store_order_product')
|
||||||
->alias('A')
|
->alias('A')
|
||||||
->where('A.uid', $arrUid)
|
->where($www2)
|
||||||
->Join('eb_store_order B', 'A.order_id = B.order_id')
|
->Join('eb_store_order B', 'A.order_id = B.order_id')
|
||||||
->field(Db::raw('sum(A.product_num) as total,A.product_id,cart_info'))
|
->field(Db::raw('sum(A.product_num) as total,A.product_id,cart_info'))
|
||||||
->withAttr('cart_info', function ($val) {
|
->withAttr('cart_info', function ($val) {
|
||||||
@ -1086,7 +1086,8 @@ class Api extends BaseController
|
|||||||
getModelTime($query, $date, 'B.pay_time');
|
getModelTime($query, $date, 'B.pay_time');
|
||||||
})->when($merId, function ($query, $merId) {
|
})->when($merId, function ($query, $merId) {
|
||||||
$query->where('B.mer_id', $merId);
|
$query->where('B.mer_id', $merId);
|
||||||
})->where('B.paid', 1)->group('A.product_id')->limit(10)->order('total DESC')->select();
|
})->where('B.paid', '1')->group('A.product_id')->limit(10)->order('total DESC')->select();
|
||||||
|
|
||||||
}, 2000 + random_int(600, 1200));
|
}, 2000 + random_int(600, 1200));
|
||||||
$result = ['data' => $res];
|
$result = ['data' => $res];
|
||||||
return table_assign(0, '', $result);
|
return table_assign(0, '', $result);
|
||||||
@ -1202,6 +1203,7 @@ class Api extends BaseController
|
|||||||
|
|
||||||
// 地域成员ID
|
// 地域成员ID
|
||||||
$arrMerId = [];
|
$arrMerId = [];
|
||||||
|
$mer_id = '';
|
||||||
foreach ($userList as $v) {
|
foreach ($userList as $v) {
|
||||||
|
|
||||||
// 如果存在服务小组的话,则取出
|
// 如果存在服务小组的话,则取出
|
||||||
@ -1227,7 +1229,7 @@ class Api extends BaseController
|
|||||||
return Db::connect('shop')
|
return Db::connect('shop')
|
||||||
->table('eb_store_product')
|
->table('eb_store_product')
|
||||||
->alias('A')
|
->alias('A')
|
||||||
->whereIn('mer_id', $arrMerId)
|
->whereIn('A.mer_id', $arrMerId)
|
||||||
->Join('eb_store_cart B', 'A.product_id = B.product_id')
|
->Join('eb_store_cart B', 'A.product_id = B.product_id')
|
||||||
->field(Db::raw('sum(B.cart_num) as total,A.product_id,A.store_name,A.image'))
|
->field(Db::raw('sum(B.cart_num) as total,A.product_id,A.store_name,A.image'))
|
||||||
->when($date, function ($query, $date) {
|
->when($date, function ($query, $date) {
|
||||||
|
@ -1943,7 +1943,13 @@ class Maintainentry extends BaseController
|
|||||||
if (empty($type) || empty($name)) {
|
if (empty($type) || empty($name)) {
|
||||||
$this->apiError('缺少参数');
|
$this->apiError('缺少参数');
|
||||||
} else {
|
} else {
|
||||||
|
// 判断是否存在
|
||||||
|
$where['name'] = $name;
|
||||||
|
$where['pid'] = $type;
|
||||||
|
$is_have = Db::table('cms_planting_type')->where($where)->find();
|
||||||
|
if($is_have){
|
||||||
|
$this->apiError('该分类已存在');
|
||||||
|
}
|
||||||
$data['name'] = $name;
|
$data['name'] = $name;
|
||||||
$data['pid'] = $type;
|
$data['pid'] = $type;
|
||||||
$data['createtime'] = time();
|
$data['createtime'] = time();
|
||||||
@ -1969,6 +1975,13 @@ class Maintainentry extends BaseController
|
|||||||
$this->apiError('缺少参数');
|
$this->apiError('缺少参数');
|
||||||
} else {
|
} else {
|
||||||
$data = get_params();
|
$data = get_params();
|
||||||
|
// 判断是否存在
|
||||||
|
$where['type_id'] = $type;
|
||||||
|
$where['user_id'] = $this->request->uid;
|
||||||
|
$is_have = Db::table('cms_planting_information')->where($where)->find();
|
||||||
|
if($is_have){
|
||||||
|
$this->apiError('请勿重复录入');
|
||||||
|
}
|
||||||
$data['user_id'] = $this->request->uid;
|
$data['user_id'] = $this->request->uid;
|
||||||
$data['createtime'] = time();
|
$data['createtime'] = time();
|
||||||
$result = Db::table('cms_planting_information')->strict(false)->insert($data);
|
$result = Db::table('cms_planting_information')->strict(false)->insert($data);
|
||||||
@ -1980,6 +1993,60 @@ class Maintainentry extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取详情(农作物、农机农具、养殖)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function get_by_id()
|
||||||
|
{
|
||||||
|
$id = get_params('id');
|
||||||
|
if (empty($id)) {
|
||||||
|
$this->apiError('缺少参数');
|
||||||
|
} else {
|
||||||
|
$data = get_params();
|
||||||
|
// 判断是否存在
|
||||||
|
$where['id'] = $id;
|
||||||
|
$where['user_id'] = $this->request->uid;
|
||||||
|
$result = Db::table('cms_planting_information')->where($where)
|
||||||
|
->withAttr('createtime', function ($val,$data) {
|
||||||
|
return date('Y-m-d H:i:s',$data['createtime']);
|
||||||
|
})
|
||||||
|
->find();
|
||||||
|
if ($result) {
|
||||||
|
$this->apiSuccess('获取成功', $result);
|
||||||
|
} else {
|
||||||
|
$this->apiError('暂无数据');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑(农作物、农机农具、养殖)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function edit_information()
|
||||||
|
{
|
||||||
|
$id = get_params('id');
|
||||||
|
if (empty($id)) {
|
||||||
|
$this->apiError('缺少参数');
|
||||||
|
} else {
|
||||||
|
$data = get_params();
|
||||||
|
// 判断是否存在
|
||||||
|
$where['id'] = $id;
|
||||||
|
$where['user_id'] = $this->request->uid;
|
||||||
|
$is_have = Db::table('cms_planting_information')->where($where)->find();
|
||||||
|
if(!$is_have){
|
||||||
|
$this->apiError('未找到该数据');
|
||||||
|
}
|
||||||
|
$result = Db::table('cms_planting_information')->where($where)->update($data);
|
||||||
|
if ($result) {
|
||||||
|
$this->apiSuccess('编辑成功', $result);
|
||||||
|
} else {
|
||||||
|
$this->apiError('编辑失败');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取列表(农作物、农机农具、养殖)
|
* 获取列表(农作物、农机农具、养殖)
|
||||||
*
|
*
|
||||||
@ -1997,7 +2064,11 @@ class Maintainentry extends BaseController
|
|||||||
$limit = get_params('limit')??10;
|
$limit = get_params('limit')??10;
|
||||||
$order = get_params('order')??'id';
|
$order = get_params('order')??'id';
|
||||||
|
|
||||||
$result = Db::table('cms_planting_information')->where($where)->page($page,$limit)->order($order. ' desc')->select()->toArray();
|
$result = Db::table('cms_planting_information')->where($where)->page($page,$limit)->order($order. ' desc')
|
||||||
|
->withAttr('createtime', function ($val,$data) {
|
||||||
|
return date('Y-m-d H:i:s',$data['createtime']);
|
||||||
|
})
|
||||||
|
->select()->toArray();
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$this->apiSuccess('获取成功', $result);
|
$this->apiSuccess('获取成功', $result);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user