1.商品详情页修改了分销推广对应的人员
2.新增本地商家接口
This commit is contained in:
parent
b18fe1c8ac
commit
dae9417eaf
@ -31,6 +31,7 @@ use app\common\model\user\UserAuth;
|
||||
use app\common\server\JsonServer;
|
||||
use think\facade\Validate;
|
||||
use weixin\Getopenid;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
class Goods extends Api
|
||||
@ -46,24 +47,47 @@ class Goods extends Api
|
||||
$goodsId = $this->request->get('goods_id', '', 'trim');
|
||||
$p_id = $this->request->get('p_id',0);
|
||||
$set_id = $this->request->get('set',0);
|
||||
$firend_invite_code = $this->request->get('firend_invite_code',0);
|
||||
$invite_code = $this->request->get('invite_code',0);
|
||||
$code = $this->request->get('code',0);
|
||||
$open=new Getopenid();
|
||||
$info=$open->getAcc($code);
|
||||
if(isset($info['openid'])) {
|
||||
$openid = $info['openid'];
|
||||
$user_msg = UserAuth::where("openid",$openid)->find();
|
||||
$firend_msg = User::where("distribution_code",$firend_invite_code)->find();
|
||||
$firend_msg = User::where("distribution_code",$invite_code)->find();
|
||||
if($user_msg==null){
|
||||
$divide_second_user_id = 0;
|
||||
$divide_role_user_id = 0;
|
||||
$firend_id = 0;
|
||||
$is_d = Db::name("distribution")->where('user_id', $firend_msg['id'] )->where('is_distribution', 1 )->find();
|
||||
if($is_d != null){
|
||||
$firend_id = $firend_msg['id'];
|
||||
if($firend_msg['divide_role_user_id']!==0){
|
||||
$divide_role_user_id = $firend_msg['divide_role_user_id'];
|
||||
}else{
|
||||
if($firend_msg['first_leader'] !=0){
|
||||
$divide_role_user_id = $firend_msg['first_leader'];
|
||||
}else{
|
||||
$divide_role_user_id = $firend_id;
|
||||
}
|
||||
}
|
||||
if($firend_msg['regional_state'] === 1){
|
||||
$divide_second_user_id = $firend_msg['id'];
|
||||
}elseif($firend_msg['divide_second_user_id']!==0){
|
||||
$divide_second_user_id = $firend_msg['divide_second_user_id'];
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'sn' => create_user_sn(),
|
||||
'create_time' => time(),
|
||||
"first_leader" => $firend_msg['id'],
|
||||
"first_leader" => $firend_id,
|
||||
'distribution_code' => generate_invite_code(),//分销邀请码
|
||||
'is_distribution' => DistributionLogic::isDistributionMember(),
|
||||
'client' => 1,
|
||||
'is_new_user' => 1,
|
||||
'user_ad_cret' => 1
|
||||
'user_ad_cret' => 1,
|
||||
'divide_role_user_id' => $divide_role_user_id,
|
||||
'divide_second_user_id'=>$divide_second_user_id
|
||||
];
|
||||
$user = User::create($data);
|
||||
$user_id = $user->id;
|
||||
@ -73,6 +97,13 @@ class Goods extends Api
|
||||
"create_time"=>time(),
|
||||
"client"=>1
|
||||
]);
|
||||
if($is_d != null){
|
||||
$firend_id = $firend_msg['id'];
|
||||
$dat['f_user_id'] = $firend_id;
|
||||
$dat['user_id'] = $user_id;
|
||||
$dat['ditme'] = date("Y-m-d H:i:s");
|
||||
Db::name("user_firster")->save($dat);
|
||||
}
|
||||
//生成会员分销扩展表
|
||||
DistributionLogic::createUserDistribution($user_id);
|
||||
|
||||
@ -101,16 +132,16 @@ class Goods extends Api
|
||||
$set = Procurementset::where("u_id",$p_id)->where("set_state",1)->order("set_update desc")->limit(1)->find();
|
||||
}
|
||||
$set_price_type = 0;
|
||||
if ($set != null&&$settpye!=1) {
|
||||
if($set['price_type']==1){
|
||||
$set_price_type = 1;
|
||||
}
|
||||
if($set['price_type']==2){
|
||||
$set_price_type = 2;
|
||||
}
|
||||
if($set['price_type']==3){
|
||||
$set_price_type = 3;
|
||||
}
|
||||
if ($set != null&&$settpye!=1) {
|
||||
if($set['price_type']==1){
|
||||
$set_price_type = 1;
|
||||
}
|
||||
if($set['price_type']==2){
|
||||
$set_price_type = 2;
|
||||
}
|
||||
if($set['price_type']==3){
|
||||
$set_price_type = 3;
|
||||
}
|
||||
if ($set['set_pro'] != 0) {
|
||||
// $set_price_type = 1;
|
||||
if ($set['set_pro_type'] == 1) {
|
||||
@ -185,7 +216,7 @@ class Goods extends Api
|
||||
}
|
||||
}
|
||||
}
|
||||
$goodsDetail['set_price_type'] = $set_price_type;
|
||||
$goodsDetail['set_price_type'] = $set_price_type;
|
||||
$rst = Mprocurement::where("user_id",$this->user_id)->where("u_state",1)->where("u_examine_state",1)->where("wholesale_state",2)->find();
|
||||
if($rst==null){
|
||||
// foreach($goodsDetail['goods_item'] as $k => $v){
|
||||
@ -289,7 +320,7 @@ class Goods extends Api
|
||||
return JsonServer::error('请求方式错误');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 根据商品名称搜索
|
||||
public function searchByName()
|
||||
{
|
||||
@ -301,8 +332,8 @@ class Goods extends Api
|
||||
return JsonServer::error('请求方式错误');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 2024-07-26 新版获取热销榜单
|
||||
public function hotList()
|
||||
{
|
||||
@ -312,7 +343,7 @@ class Goods extends Api
|
||||
|
||||
return JsonServer::success('获取成功', $list);
|
||||
}
|
||||
|
||||
|
||||
public function newGoods()
|
||||
{
|
||||
// 等于1是获取4条推荐商品 等于2是获取全部的商品
|
||||
@ -323,5 +354,5 @@ class Goods extends Api
|
||||
$list = GoodsLogic::goodsList($type, $page, $size);
|
||||
return JsonServer::success('获取成功', $list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -8,6 +8,7 @@ use app\common\model\user\User;
|
||||
use app\common\server\JsonServer;
|
||||
use app\common\server\UrlServer;
|
||||
use app\common\server\WeChatServer;
|
||||
use app\api\logic\LocalStoreLogic;
|
||||
use EasyWeChat\Factory;
|
||||
use think\facade\Db;
|
||||
use think\facade\Config as FileConfig;
|
||||
@ -25,7 +26,13 @@ class LocalStore extends Api
|
||||
$data['set_state'] = 1;
|
||||
return JsonServer::success('查询成功',$data);
|
||||
}
|
||||
|
||||
// 查询本地商家
|
||||
public function getLocalList(){
|
||||
$model = new LocalStoreLogic;
|
||||
$data = $this->request->param();
|
||||
$result = $model->getLocalList($data);
|
||||
return JsonServer::success('查询成功',$result);
|
||||
}
|
||||
public function addLocalStore()
|
||||
{
|
||||
$user_id = $this->user_id;
|
||||
@ -103,7 +110,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();
|
||||
|
||||
@ -128,7 +135,6 @@ class LocalStore extends Api
|
||||
|
||||
return JsonServer::success('查询成功', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
*生成本地商家支付二维码
|
||||
*/
|
||||
|
||||
58
app/api/logic/LocalStoreLogic.php
Normal file
58
app/api/logic/LocalStoreLogic.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\basics\Logic;
|
||||
use app\common\model\LocalStore;
|
||||
use think\facade\Db;
|
||||
|
||||
class LocalStoreLogic extends Logic
|
||||
{
|
||||
public function getLocalList($data){
|
||||
$model = new LocalStore;
|
||||
$distance = "";
|
||||
$s = "address like '%".$data['search']."%'";
|
||||
$count = $model->where('is_delete',0)
|
||||
->where($s)
|
||||
->count();
|
||||
// $lists = $model->where('is_delete',0)
|
||||
// ->where($s)
|
||||
// ->page($data['page'], $data['size'])
|
||||
// ->order('lstore_id desc')
|
||||
// ->select();
|
||||
$page = ($data['page']-1)*$data['size'];
|
||||
$sql = "SELECT *, ST_Distance_Sphere(POINT(".$data['longitude'].",".$data['latitude']."),POINT(longitude, latitude)) AS distance
|
||||
FROM ls_local_store where is_delete = 0 $s
|
||||
ORDER BY distance limit '".$page."','".$data['size']."'";
|
||||
$lists = Db::query($sql);
|
||||
foreach($lists as $key=>$value){
|
||||
$lists[$key]['distance'] = $this->distance($data['latitude'], $data['longitude'], $value['latitude'], $value['longitude']);
|
||||
}
|
||||
$data = [
|
||||
'list' => $lists,
|
||||
'page' => $data['page'],
|
||||
'size' => $data['size'],
|
||||
'count' => $count,
|
||||
'more' => is_more($count, $data['page'], $data['size'])
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
function distance($lat1, $lon1, $lat2, $lon2) {
|
||||
$earthRadius = 6371000; // 地球平均半径,单位为米
|
||||
|
||||
// 将经纬度转换为弧度
|
||||
$lat1 = deg2rad($lat1);
|
||||
$lon1 = deg2rad($lon1);
|
||||
$lat2 = deg2rad($lat2);
|
||||
$lon2 = deg2rad($lon2);
|
||||
|
||||
// 使用haversine公式计算距离
|
||||
$diffLat = $lat2-$lat1;
|
||||
$diffLon = $lon2-$lon1;
|
||||
$a = sin($diffLat / 2) * sin($diffLat / 2) + cos($lat1) * cos($lat2) * sin($diffLon / 2) * sin($diffLon / 2);
|
||||
$c = 2 * atan2(sqrt($a), sqrt(1-$a));
|
||||
$distance = $earthRadius * $c;
|
||||
|
||||
return $distance;
|
||||
}
|
||||
}
|
||||
10
app/common/model/localstore/LocalStore.php
Normal file
10
app/common/model/localstore/LocalStore.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\localstore;
|
||||
|
||||
use app\common\basics\Models;
|
||||
|
||||
class LocalStore extends Models
|
||||
{
|
||||
protected $table = 'ls_local_store';
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user