解析post_station
This commit is contained in:
parent
7845c62734
commit
8f3b9b2411
@ -2,17 +2,16 @@
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\LocalStoreLogic;
|
||||
use app\common\basics\Api;
|
||||
use app\common\enum\NoticeEnum;
|
||||
use app\common\model\user\User;
|
||||
use app\common\server\ConfigServer;
|
||||
use app\common\server\JsonServer;
|
||||
use app\common\server\WeChatServer;
|
||||
use app\api\logic\LocalStoreLogic;
|
||||
use EasyWeChat\Factory;
|
||||
use think\facade\Db;
|
||||
use think\facade\Config as FileConfig;
|
||||
use app\api\validate\LocalStoreGoodsValidate;
|
||||
use think\facade\Db;
|
||||
|
||||
class LocalStore extends Api
|
||||
{
|
||||
@ -29,46 +28,53 @@ class LocalStore extends Api
|
||||
}
|
||||
$data['local'] = $result;
|
||||
$data['set_state'] = 1;
|
||||
return JsonServer::success('查询成功',$data);
|
||||
return JsonServer::success('查询成功', $data);
|
||||
}
|
||||
|
||||
// 查询本地商家
|
||||
public function getLocalList(){
|
||||
public function getLocalList()
|
||||
{
|
||||
$model = new LocalStoreLogic;
|
||||
$data = $this->request->param();
|
||||
$result = $model->getLocalList($data);
|
||||
return JsonServer::success('查询成功',$result);
|
||||
return JsonServer::success('查询成功', $result);
|
||||
}
|
||||
|
||||
// 查询本地商户订单
|
||||
public function getLocalOrderList(){
|
||||
public function getLocalOrderList()
|
||||
{
|
||||
$model = new LocalStoreLogic;
|
||||
$data = $this->request->param();
|
||||
$result = $model->getLocalOrderList($data);
|
||||
return JsonServer::success('查询成功',$result);
|
||||
return JsonServer::success('查询成功', $result);
|
||||
}
|
||||
|
||||
// 查询本地商户用户订单
|
||||
public function getLocalUserOrderList(){
|
||||
public function getLocalUserOrderList()
|
||||
{
|
||||
$model = new LocalStoreLogic;
|
||||
$data = $this->request->param();
|
||||
$user_id = $this->user_id;
|
||||
$data['user_id'] = $user_id;
|
||||
$result = $model->getLocalUserOrderList($data);
|
||||
return JsonServer::success('查询成功',$result);
|
||||
return JsonServer::success('查询成功', $result);
|
||||
}
|
||||
|
||||
public function addLocalStore()
|
||||
{
|
||||
$user_id = $this->user_id;
|
||||
$data = $this->request->param();
|
||||
if(isset($data['lstore_id']) && $data['lstore_id'] != 0){
|
||||
if (isset($data['lstore_id']) && $data['lstore_id'] != 0) {
|
||||
$data['store_state'] = 0;
|
||||
$data['update_time'] = date("Y-m-d H:i:s");
|
||||
$result = Db::name("local_store")->where("lstore_id",$data['lstore_id'])->save($data);
|
||||
}else {
|
||||
$result = Db::name("local_store")->where("lstore_id", $data['lstore_id'])->save($data);
|
||||
} else {
|
||||
$data['user_id'] = $user_id;
|
||||
$data['create_time'] = date("Y-m-d H:i:s");
|
||||
$result = Db::name("local_store")->save($data);
|
||||
}
|
||||
|
||||
if($result){
|
||||
if ($result) {
|
||||
event('Notice', [
|
||||
'scene' => NoticeEnum::LOCAL_SHOP_SETTLED_NOTICE,
|
||||
'mobile' => 18436015360, // 张慧娟的手机号码
|
||||
@ -78,7 +84,7 @@ class LocalStore extends Api
|
||||
]
|
||||
]);
|
||||
return JsonServer::success('上传成功');
|
||||
}else{
|
||||
} else {
|
||||
return JsonServer::error('上传失败');
|
||||
}
|
||||
}
|
||||
@ -86,8 +92,8 @@ class LocalStore extends Api
|
||||
// 查询协议
|
||||
public function checkTreaty()
|
||||
{
|
||||
$result = Db::name("procurement_treaty")->where("id",1)->find();
|
||||
return JsonServer::success('查询成功',$result);
|
||||
$result = Db::name("procurement_treaty")->where("id", 1)->find();
|
||||
return JsonServer::success('查询成功', $result);
|
||||
|
||||
}
|
||||
|
||||
@ -99,12 +105,12 @@ class LocalStore extends Api
|
||||
$lists = Db::name('local_store')
|
||||
->where(['user_id' => $this->user_id, 'store_state' => 1, 'is_delete' => 0])
|
||||
->order('create_time', 'desc')
|
||||
->page($page,$size)
|
||||
->page($page, $size)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$count = Db::name('local_store')
|
||||
->where(['user_id' => $this->user_id, 'store_state' => 1 , 'is_delete' => 0])
|
||||
->where(['user_id' => $this->user_id, 'store_state' => 1, 'is_delete' => 0])
|
||||
->count();
|
||||
|
||||
$more = is_more($count, $page, $size); //是否有下一页
|
||||
@ -127,7 +133,7 @@ class LocalStore extends Api
|
||||
$lists = Db::name('local_store')
|
||||
->where(['store_state' => 1])
|
||||
->order('create_time', 'desc')
|
||||
->page($page,$size)
|
||||
->page($page, $size)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
@ -152,34 +158,36 @@ class LocalStore extends Api
|
||||
|
||||
return JsonServer::success('查询成功', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
*生成本地商家支付二维码
|
||||
*/
|
||||
public function makeMyPayImage(){
|
||||
public function makeMyPayImage()
|
||||
{
|
||||
// $user_id = 2;
|
||||
$user_id = $this->user_id;
|
||||
$lstore_id = $this->request->post('lstore_id');
|
||||
$user_msg = User::where("id",$user_id)->where("del",0)->where("disable",0)->find();
|
||||
if($user_msg==null){
|
||||
$user_msg = User::where("id", $user_id)->where("del", 0)->where("disable", 0)->find();
|
||||
if ($user_msg == null) {
|
||||
return JsonServer::error('暂无用户');
|
||||
}
|
||||
$user_local_msg = Db::name("local_store")->where("user_id",$user_id)->where("store_state",1)->find();
|
||||
if ($user_local_msg!= null) {
|
||||
if($user_local_msg['pay_image'] != null){
|
||||
$user_local_msg = Db::name("local_store")->where("user_id", $user_id)->where("store_state", 1)->find();
|
||||
if ($user_local_msg != null) {
|
||||
if ($user_local_msg['pay_image'] != null) {
|
||||
$data['pay_image'] = $user_local_msg['pay_image'];
|
||||
return JsonServer::success('查询成功',$data);
|
||||
}else{
|
||||
return JsonServer::success('查询成功', $data);
|
||||
} else {
|
||||
$url = "bundle_b/pages/local_shop/local_pay";
|
||||
$save_dir = ROOT_PATH .'/uploads/localpay/';
|
||||
$scene = 'lid='.$lstore_id;
|
||||
$a = time().$scene;
|
||||
$save_dir = ROOT_PATH . '/uploads/localpay/';
|
||||
$scene = 'lid=' . $lstore_id;
|
||||
$a = time() . $scene;
|
||||
$qr_src = $a . '.jpg';
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
$url = "bundle_b/pages/local_shop/local_pay";
|
||||
$save_dir = ROOT_PATH .'/uploads/localpay/';
|
||||
$scene = 'lid='.$lstore_id;
|
||||
$a = time().$scene;
|
||||
$save_dir = ROOT_PATH . '/uploads/localpay/';
|
||||
$scene = 'lid=' . $lstore_id;
|
||||
$a = time() . $scene;
|
||||
$qr_src = $a . '.jpg';
|
||||
}
|
||||
try {
|
||||
@ -187,7 +195,7 @@ class LocalStore extends Api
|
||||
$app = Factory::miniProgram($config);
|
||||
|
||||
$response = $app->app_code->getUnlimit($scene, [
|
||||
'page' => $url
|
||||
'page' => $url
|
||||
// 'env_version' => 'trial',
|
||||
// 'env_version' => 'develop'
|
||||
]);
|
||||
@ -196,19 +204,19 @@ class LocalStore extends Api
|
||||
if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
|
||||
$response->saveAs($save_dir, $a);
|
||||
$us = \think\facade\Request::instance()->domain();
|
||||
$data['pay_image'] = $us.'/uploads/localpay/'.$qr_src;
|
||||
$user_msg = Db::name("local_store")->where("lstore_id",$lstore_id)->update($data);
|
||||
if($user_msg){
|
||||
return JsonServer::success('查询成功',$data);
|
||||
}else{
|
||||
$data['pay_image'] = $us . '/uploads/localpay/' . $qr_src;
|
||||
$user_msg = Db::name("local_store")->where("lstore_id", $lstore_id)->update($data);
|
||||
if ($user_msg) {
|
||||
return JsonServer::success('查询成功', $data);
|
||||
} else {
|
||||
return JsonServer::error('查询失败');
|
||||
}
|
||||
}
|
||||
if(isset($response['errcode']) && 41030 === $response['errcode']){
|
||||
if (isset($response['errcode']) && 41030 === $response['errcode']) {
|
||||
return '商城小程序未上线或商城小程序页面发布';
|
||||
}
|
||||
return $response['errmsg'];
|
||||
} catch (\EasyWeChat\Kernel\Exceptions\Exception $e){
|
||||
} catch (\EasyWeChat\Kernel\Exceptions\Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
@ -216,24 +224,28 @@ class LocalStore extends Api
|
||||
public function getLocalShopById()
|
||||
{
|
||||
$id = $this->request->post('id');
|
||||
$latitude = $this->request->post('latitude',0);
|
||||
$longitude = $this->request->post('longitude',0);
|
||||
$type = $this->request->post('type',0);
|
||||
$latitude = $this->request->post('latitude', 0);
|
||||
$longitude = $this->request->post('longitude', 0);
|
||||
$type = $this->request->post('type', 0);
|
||||
$user_id = $this->user_id;
|
||||
$u = "";
|
||||
if($type == 0){
|
||||
if ($type == 0) {
|
||||
$u = "user_id = $user_id";
|
||||
}
|
||||
$result = Db::name('local_store')
|
||||
->where('lstore_id',$id)
|
||||
->where('store_state',1)
|
||||
->where('lstore_id', $id)
|
||||
->where('store_state', 1)
|
||||
->where($u)
|
||||
->order('create_time desc')
|
||||
->find();
|
||||
if ($result) {
|
||||
$model = new LocalStoreLogic;
|
||||
$result['distance']=round($model->distance($result['latitude'],$result['longitude'],$latitude,$longitude)/1000,2)."公里";
|
||||
$result['header_image'] = FileConfig::get('aliyunoss.domain') . 'local_life_shop/' . $result['header_image'] ;
|
||||
if ($result) {
|
||||
$model = new LocalStoreLogic;
|
||||
$result['distance'] = round($model->distance($result['latitude'], $result['longitude'], $latitude, $longitude) / 1000, 2) . "公里";
|
||||
$result['header_image'] = FileConfig::get('aliyunoss.domain') . 'local_life_shop/' . $result['header_image'];
|
||||
|
||||
if ($result['post_station']) {
|
||||
$result['post_station'] = json_decode($result['post_station'], true);
|
||||
}
|
||||
return JsonServer::success('成功获取', $result);
|
||||
}
|
||||
|
||||
@ -276,36 +288,40 @@ class LocalStore extends Api
|
||||
}
|
||||
|
||||
//下单购买商品
|
||||
public function submitLocalOrder(){
|
||||
public function submitLocalOrder()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$user_id = $this->user_id;
|
||||
$data = LocalStoreLogic::submitOrder($post,$user_id);
|
||||
if($data === -1){
|
||||
$data = LocalStoreLogic::submitOrder($post, $user_id);
|
||||
if ($data === -1) {
|
||||
return JsonServer::error('库存不足');
|
||||
}
|
||||
return JsonServer::success('下单成功', $data);
|
||||
}
|
||||
|
||||
// 订单详情
|
||||
public function localOrderDetails(){
|
||||
public function localOrderDetails()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$data = LocalStoreLogic::orderDetails($post);
|
||||
return JsonServer::success('查询成功', $data);
|
||||
}
|
||||
|
||||
// 取消订单
|
||||
public function cancelLocalOrder(){
|
||||
public function cancelLocalOrder()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$data = LocalStoreLogic::cancelOrder($post);
|
||||
if($data){
|
||||
if ($data) {
|
||||
return JsonServer::success('取消成功');
|
||||
}else{
|
||||
} else {
|
||||
return JsonServer::error('取消失败');
|
||||
}
|
||||
}
|
||||
|
||||
// 我的订单
|
||||
public function localMyOrderList(){
|
||||
public function localMyOrderList()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$user_id = $this->user_id;
|
||||
$post['user_id'] = $user_id;
|
||||
@ -314,7 +330,8 @@ class LocalStore extends Api
|
||||
}
|
||||
|
||||
// 店铺订单列表
|
||||
public function localOrderList(){
|
||||
public function localOrderList()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$data = LocalStoreLogic::orderList($post);
|
||||
return JsonServer::success('查询成功', $data);
|
||||
@ -331,7 +348,7 @@ class LocalStore extends Api
|
||||
if ($data['message'] == 'Success') {
|
||||
return JsonServer::success('', $data['result']['location']);
|
||||
}
|
||||
} catch(\Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
return JsonServer::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
@ -343,7 +360,7 @@ class LocalStore extends Api
|
||||
$post = $this->request->post();
|
||||
LocalStoreLogic::setPostStation($post, $this->user_id);
|
||||
return JsonServer::success('设置成功');
|
||||
} catch(\Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
return JsonServer::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user