用户获取已绑定列表
This commit is contained in:
parent
782c4e24fe
commit
c72558e522
@ -416,7 +416,7 @@ class LocalStore extends Api
|
||||
}
|
||||
}
|
||||
|
||||
//解绑用户
|
||||
// 解绑用户
|
||||
public function unbindUser()
|
||||
{
|
||||
try {
|
||||
@ -427,4 +427,13 @@ class LocalStore extends Api
|
||||
return JsonServer::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 是否在绑定列表中
|
||||
public function inBindList()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
$page = $this->request->get('page_no', $this->page_no);
|
||||
$size = $this->request->get('page_size', $this->page_size);
|
||||
return JsonServer::success('', LocalStoreLogic::inBindList($this->user_id, $page, $size));
|
||||
}
|
||||
}
|
||||
@ -9,11 +9,9 @@ use app\common\model\localstore\LocalStoreBind;
|
||||
use app\common\model\LocalStoreOrder;
|
||||
use app\common\model\LocalStorePostStation;
|
||||
use app\common\model\user\User;
|
||||
use app\common\server\FileServer;
|
||||
use app\common\server\UrlServer;
|
||||
use think\db\Where;
|
||||
use think\facade\Db;
|
||||
use think\facade\Config;
|
||||
use think\facade\Db;
|
||||
|
||||
class LocalStoreLogic extends Logic
|
||||
{
|
||||
@ -63,7 +61,7 @@ class LocalStoreLogic extends Logic
|
||||
// if (isset($data['c_name']) && $data['c_name'] == '嘉兴市') {
|
||||
// $sql = "SELECT * FROM ls_local_store where lstore_id = 138 and is_delete = 0 and store_state = 1 and shopLogo is not null $s ORDER BY lstore_id asc limit " . $page . "," . $size;
|
||||
// } else {
|
||||
$sql = "SELECT * FROM ls_local_store where is_delete = 0 and store_state = 1 and shopLogo is not null $s $keyword ORDER BY lstore_id asc limit " . $page . "," . $size;
|
||||
$sql = "SELECT * FROM ls_local_store where is_delete = 0 and store_state = 1 and shopLogo is not null $s $keyword ORDER BY lstore_id asc limit " . $page . "," . $size;
|
||||
// }
|
||||
|
||||
// var_dump($sql);
|
||||
@ -224,27 +222,28 @@ class LocalStoreLogic extends Logic
|
||||
];
|
||||
}
|
||||
|
||||
public static function submitOrder($post,$user_id){
|
||||
$goods_msg = Db::name("local_store_goods")->where("id",$post['goods_id'])->find();
|
||||
if($post['item_id'] > 0){
|
||||
if($goods_msg['is_multiple_spec']>0){
|
||||
$goods_sku_msg = Db::name("local_store_goods_item")->where("id",$post['item_id'])->find();
|
||||
if($goods_sku_msg['stock']<$post['goods_num']){
|
||||
public static function submitOrder($post, $user_id)
|
||||
{
|
||||
$goods_msg = Db::name("local_store_goods")->where("id", $post['goods_id'])->find();
|
||||
if ($post['item_id'] > 0) {
|
||||
if ($goods_msg['is_multiple_spec'] > 0) {
|
||||
$goods_sku_msg = Db::name("local_store_goods_item")->where("id", $post['item_id'])->find();
|
||||
if ($goods_sku_msg['stock'] < $post['goods_num']) {
|
||||
return -1;
|
||||
}
|
||||
$data['goods_total_price'] = round($goods_sku_msg['price']*$post['goods_num'],2);
|
||||
$data['goods_total_price'] = round($goods_sku_msg['price'] * $post['goods_num'], 2);
|
||||
Db::name("local_store_goods_item")
|
||||
->where("id",$post['item_id'])
|
||||
->dec("stock",$post['goods_num'])
|
||||
->where("id", $post['item_id'])
|
||||
->dec("stock", $post['goods_num'])
|
||||
->update();
|
||||
}else{
|
||||
$data['goods_total_price'] = round($goods_msg['price']*$post['goods_num'],2);
|
||||
} else {
|
||||
$data['goods_total_price'] = round($goods_msg['price'] * $post['goods_num'], 2);
|
||||
}
|
||||
}else{
|
||||
$data['goods_total_price'] = round($goods_msg['price']*$post['goods_num'],2);
|
||||
} else {
|
||||
$data['goods_total_price'] = round($goods_msg['price'] * $post['goods_num'], 2);
|
||||
|
||||
}
|
||||
$data['order_no'] = createSn('local_goods_order', 'order_no');
|
||||
$data['order_no'] = createSn('local_goods_order', 'order_no');
|
||||
$data['lstore_id'] = $post['lstore_id'];
|
||||
$data['item_id'] = $post['item_id'];
|
||||
$data['goods_id'] = $post['goods_id'];
|
||||
@ -256,92 +255,95 @@ class LocalStoreLogic extends Logic
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function orderDetails($post){
|
||||
$result = Db::name("local_goods_order")->where("lsg_order_id",$post['lsg_order_id'])->find();
|
||||
$goods = Db::name("local_store_goods")->where("id",$result['goods_id'])->find();
|
||||
public static function orderDetails($post)
|
||||
{
|
||||
$result = Db::name("local_goods_order")->where("lsg_order_id", $post['lsg_order_id'])->find();
|
||||
$goods = Db::name("local_store_goods")->where("id", $result['goods_id'])->find();
|
||||
$result['goods_msg'] = $goods;
|
||||
$image = Db::name("local_store_goods_pic")->where("lsg_id",$result['goods_id'])->select()->toArray();
|
||||
foreach($image as $k=>$v){
|
||||
$image[$k]['url'] = Config::get('aliyunoss.domain').$v['url'];
|
||||
$image = Db::name("local_store_goods_pic")->where("lsg_id", $result['goods_id'])->select()->toArray();
|
||||
foreach ($image as $k => $v) {
|
||||
$image[$k]['url'] = Config::get('aliyunoss.domain') . $v['url'];
|
||||
}
|
||||
$result['goods_image'] = $image;
|
||||
$item = Db::name("local_store_goods_item")->where("id",$result['item_id'])->find();
|
||||
if($item != null){
|
||||
$item['image'] = Config::get('aliyunoss.domain').$item['image'];
|
||||
$item = Db::name("local_store_goods_item")->where("id", $result['item_id'])->find();
|
||||
if ($item != null) {
|
||||
$item['image'] = Config::get('aliyunoss.domain') . $item['image'];
|
||||
}
|
||||
$result['sku_msg'] = $item;
|
||||
$local = Db::name("local_store")->field("shopName,shopLogo")->where("lstore_id",$result['lstore_id'])->find();
|
||||
$local = Db::name("local_store")->field("shopName,shopLogo")->where("lstore_id", $result['lstore_id'])->find();
|
||||
$result['local_msg'] = $local;
|
||||
return $result;
|
||||
}
|
||||
public static function cancelOrder($post){
|
||||
|
||||
public static function cancelOrder($post)
|
||||
{
|
||||
$result = Db::name("local_goods_order")
|
||||
->where("lsg_order_id",$post['lsg_order_id'])
|
||||
->where("lsg_order_id", $post['lsg_order_id'])
|
||||
->find();
|
||||
if($result['item_id']>0){
|
||||
if ($result['item_id'] > 0) {
|
||||
Db::name("local_store_goods_item")
|
||||
->where("id",$result['item_id'])
|
||||
->inc("stock",$result['goods_num'])
|
||||
->where("id", $result['item_id'])
|
||||
->inc("stock", $result['goods_num'])
|
||||
->update();
|
||||
}
|
||||
$res = Db::name("local_goods_order")
|
||||
->where("lsg_order_id",$post['lsg_order_id'])
|
||||
->update(["state"=>2]);
|
||||
$res = Db::name("local_goods_order")
|
||||
->where("lsg_order_id", $post['lsg_order_id'])
|
||||
->update(["state" => 2]);
|
||||
return $res;
|
||||
}
|
||||
|
||||
public static function myOrderList($post)
|
||||
{
|
||||
$s = "";
|
||||
if(isset($post['state'])){
|
||||
$s = "state= ".$post['state']."";
|
||||
if (isset($post['state'])) {
|
||||
$s = "state= " . $post['state'] . "";
|
||||
}
|
||||
$list = LocalGoodsStore::where('user_id',$post['user_id'])
|
||||
$list = LocalGoodsStore::where('user_id', $post['user_id'])
|
||||
->where($s)
|
||||
->where("state <> 3")
|
||||
->page($post['page_no'], $post['page_size'])
|
||||
->order('dtime desc')
|
||||
->select()
|
||||
->toArray();
|
||||
foreach($list as $key=>$value){
|
||||
$goods = Db::name("local_store_goods")->where("id",$value['goods_id'])->find();
|
||||
$image = Db::name("local_store_goods_pic")->where("lsg_id",$value['goods_id'])->select()->toArray();
|
||||
foreach($image as $k=>$v){
|
||||
$image[$k]['url'] = Config::get('aliyunoss.domain').$v['url'];
|
||||
foreach ($list as $key => $value) {
|
||||
$goods = Db::name("local_store_goods")->where("id", $value['goods_id'])->find();
|
||||
$image = Db::name("local_store_goods_pic")->where("lsg_id", $value['goods_id'])->select()->toArray();
|
||||
foreach ($image as $k => $v) {
|
||||
$image[$k]['url'] = Config::get('aliyunoss.domain') . $v['url'];
|
||||
}
|
||||
$sku_msg = Db::name("local_store_goods_item")
|
||||
$sku_msg = Db::name("local_store_goods_item")
|
||||
->field("image,spec_value_str")
|
||||
->where("id",$value['item_id'])
|
||||
->where("id", $value['item_id'])
|
||||
->find();
|
||||
if($sku_msg != null){
|
||||
$sku_msg['image'] = Config::get('aliyunoss.domain').$sku_msg['image'];
|
||||
if ($sku_msg != null) {
|
||||
$sku_msg['image'] = Config::get('aliyunoss.domain') . $sku_msg['image'];
|
||||
}
|
||||
$list[$key]['sku_msg'] = $sku_msg;
|
||||
$list[$key]['goods_msg'] = $goods;
|
||||
$list[$key]['goods_image'] = $image;
|
||||
$local = Db::name("local_store")->field("shopName,shopLogo")->where("lstore_id",$value['lstore_id'])->find();
|
||||
$post_station = Db::name('local_store_post_station')->where('id',$value['post_station_id'])->find();
|
||||
$local = Db::name("local_store")->field("shopName,shopLogo")->where("lstore_id", $value['lstore_id'])->find();
|
||||
$post_station = Db::name('local_store_post_station')->where('id', $value['post_station_id'])->find();
|
||||
$list[$key]['post_station'] = $post_station;
|
||||
$list[$key]['local_msg'] = $local;
|
||||
$list[$key]['post_station_time'] = date("m-d", $value['post_station_time']);
|
||||
}
|
||||
$count = LocalGoodsStore::where('user_id',$post['user_id'])
|
||||
$count = LocalGoodsStore::where('user_id', $post['user_id'])
|
||||
->where($s)
|
||||
->where("state <> 3")
|
||||
->count();
|
||||
$all_count = LocalGoodsStore::where('user_id',$post['user_id'])
|
||||
$all_count = LocalGoodsStore::where('user_id', $post['user_id'])
|
||||
->where("state <> 3")
|
||||
->count();
|
||||
$wait_count = LocalGoodsStore::where('user_id',$post['user_id'])
|
||||
->where("state",0)
|
||||
$wait_count = LocalGoodsStore::where('user_id', $post['user_id'])
|
||||
->where("state", 0)
|
||||
->where("state <> 3")
|
||||
->count();
|
||||
$already_count = LocalGoodsStore::where('user_id',$post['user_id'])
|
||||
->where("state",1)
|
||||
$already_count = LocalGoodsStore::where('user_id', $post['user_id'])
|
||||
->where("state", 1)
|
||||
->where("state <> 3")
|
||||
->count();
|
||||
$cancel_count = LocalGoodsStore::where('user_id',$post['user_id'])
|
||||
->where("state",2)
|
||||
$cancel_count = LocalGoodsStore::where('user_id', $post['user_id'])
|
||||
->where("state", 2)
|
||||
->where("state <> 3")
|
||||
->count();
|
||||
$more = is_more($count, $post['page_no'], $post['page_size']); //是否有下一页
|
||||
@ -351,7 +353,7 @@ class LocalStoreLogic extends Logic
|
||||
'page_no' => $post['page_no'],
|
||||
'page_size' => $post['page_size'],
|
||||
'count' => $count,
|
||||
'all_count'=>$all_count,
|
||||
'all_count' => $all_count,
|
||||
'wait_count' => $wait_count,
|
||||
'already_count' => $already_count,
|
||||
'cancel_count' => $cancel_count,
|
||||
@ -362,52 +364,52 @@ class LocalStoreLogic extends Logic
|
||||
public static function orderList($post)
|
||||
{
|
||||
$s = "";
|
||||
if(isset($post['state'])){
|
||||
$s = "state= ".$post['state']."";
|
||||
if (isset($post['state'])) {
|
||||
$s = "state= " . $post['state'] . "";
|
||||
}
|
||||
$list = LocalGoodsStore::where('lstore_id',$post['lstore_id'])
|
||||
$list = LocalGoodsStore::where('lstore_id', $post['lstore_id'])
|
||||
->where($s)
|
||||
->where("state <> 3")
|
||||
->page($post['page_no'], $post['page_size'])
|
||||
->order('dtime desc')
|
||||
->select()
|
||||
->toArray();
|
||||
foreach($list as $key=>$value){
|
||||
$goods = Db::name("local_store_goods")->where("id",$value['goods_id'])->find();
|
||||
$image = Db::name("local_store_goods_pic")->where("lsg_id",$value['goods_id'])->select()->toArray();
|
||||
foreach($image as $k=>$v){
|
||||
$image[$k]['url'] = Config::get('aliyunoss.domain').$v['url'];
|
||||
foreach ($list as $key => $value) {
|
||||
$goods = Db::name("local_store_goods")->where("id", $value['goods_id'])->find();
|
||||
$image = Db::name("local_store_goods_pic")->where("lsg_id", $value['goods_id'])->select()->toArray();
|
||||
foreach ($image as $k => $v) {
|
||||
$image[$k]['url'] = Config::get('aliyunoss.domain') . $v['url'];
|
||||
}
|
||||
$sku_msg = Db::name("local_store_goods_item")
|
||||
$sku_msg = Db::name("local_store_goods_item")
|
||||
->field("image,spec_value_str")
|
||||
->where("id",$value['item_id'])
|
||||
->where("id", $value['item_id'])
|
||||
->find();
|
||||
if($sku_msg != null){
|
||||
$sku_msg['image'] = Config::get('aliyunoss.domain').$sku_msg['image'];
|
||||
if ($sku_msg != null) {
|
||||
$sku_msg['image'] = Config::get('aliyunoss.domain') . $sku_msg['image'];
|
||||
}
|
||||
$list[$key]['sku_msg'] = $sku_msg;
|
||||
$list[$key]['goods_msg'] = $goods;
|
||||
$list[$key]['goods_image'] = $image;
|
||||
$local = Db::name("local_store")->field("shopName,shopLogo")->where("lstore_id",$value['lstore_id'])->find();
|
||||
$local = Db::name("local_store")->field("shopName,shopLogo")->where("lstore_id", $value['lstore_id'])->find();
|
||||
$list[$key]['local_msg'] = $local;
|
||||
}
|
||||
$count = LocalGoodsStore::where('lstore_id',$post['lstore_id'])
|
||||
$count = LocalGoodsStore::where('lstore_id', $post['lstore_id'])
|
||||
->where($s)
|
||||
->where("state <> 3")
|
||||
->count();
|
||||
$all_count = LocalGoodsStore::where('lstore_id',$post['lstore_id'])
|
||||
$all_count = LocalGoodsStore::where('lstore_id', $post['lstore_id'])
|
||||
->where("state <> 3")
|
||||
->count();
|
||||
$wait_count = LocalGoodsStore::where('lstore_id',$post['lstore_id'])
|
||||
->where("state",0)
|
||||
$wait_count = LocalGoodsStore::where('lstore_id', $post['lstore_id'])
|
||||
->where("state", 0)
|
||||
->where("state <> 3")
|
||||
->count();
|
||||
$already_count = LocalGoodsStore::where('lstore_id',$post['lstore_id'])
|
||||
->where("state",1)
|
||||
$already_count = LocalGoodsStore::where('lstore_id', $post['lstore_id'])
|
||||
->where("state", 1)
|
||||
->where("state <> 3")
|
||||
->count();
|
||||
$cancel_count = LocalGoodsStore::where('lstore_id',$post['lstore_id'])
|
||||
->where("state",2)
|
||||
$cancel_count = LocalGoodsStore::where('lstore_id', $post['lstore_id'])
|
||||
->where("state", 2)
|
||||
->where("state <> 3")
|
||||
->count();
|
||||
$more = is_more($count, $post['page_no'], $post['page_size']); //是否有下一页
|
||||
@ -417,7 +419,7 @@ class LocalStoreLogic extends Logic
|
||||
'page_no' => $post['page_no'],
|
||||
'page_size' => $post['page_size'],
|
||||
'count' => $count,
|
||||
'all_count'=>$all_count,
|
||||
'all_count' => $all_count,
|
||||
'wait_count' => $wait_count,
|
||||
'already_count' => $already_count,
|
||||
'cancel_count' => $cancel_count,
|
||||
@ -526,7 +528,7 @@ class LocalStoreLogic extends Logic
|
||||
|
||||
public static function bindUser($post)
|
||||
{
|
||||
if ($post['user']['id'] <=0 ) {
|
||||
if ($post['user']['id'] <= 0) {
|
||||
throw new \Exception('缺少用户ID');
|
||||
}
|
||||
|
||||
@ -557,7 +559,7 @@ class LocalStoreLogic extends Logic
|
||||
|
||||
public static function unbindUser($post)
|
||||
{
|
||||
if ($post['id'] <=0 ) {
|
||||
if ($post['id'] <= 0) {
|
||||
throw new \Exception('缺少ID');
|
||||
}
|
||||
|
||||
@ -567,9 +569,31 @@ class LocalStoreLogic extends Logic
|
||||
]);
|
||||
|
||||
if ($result) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new \Exception('解绑失败');
|
||||
}
|
||||
|
||||
public static function inBindList($user_id, $page, $size)
|
||||
{
|
||||
$list = LocalStoreBind::alias('lsb')
|
||||
->join('local_store ls', 'lsb.lstore_id = ls.lstore_id')
|
||||
->where(['bind_user_id' => $user_id, 'is_unbind' => 0])
|
||||
->field('lsb.*, ls.shopName, ls.shopLogo')
|
||||
->page($page, $size)
|
||||
->select();
|
||||
|
||||
$count = LocalStoreBind::where(['bind_user_id' => $user_id, 'is_unbind' => 0])->count();
|
||||
|
||||
$data = [
|
||||
'list' => $list,
|
||||
'page' => $page,
|
||||
'size' => $size,
|
||||
'count' => $count,
|
||||
'more' => is_more($count, $page, $size)
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user