添加获取行政区域,用户邀请商户记录
This commit is contained in:
parent
0afaadb797
commit
dd7176a4fd
@ -44,8 +44,10 @@ use crmeb\services\WechatService;
|
||||
use Exception;
|
||||
use Joypack\Tencent\Map\Bundle\Location;
|
||||
use Joypack\Tencent\Map\Bundle\LocationOption;
|
||||
use Overtrue\Pinyin\Pinyin;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
use think\Response;
|
||||
|
||||
@ -563,4 +565,102 @@ class Common extends BaseController
|
||||
$data['config'] = systemConfig(['open_screen_switch','open_screen_time','open_screen_space']);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序版本
|
||||
*/
|
||||
public function applet()
|
||||
{
|
||||
$group_id = Db::name('system_group')->where('group_key', 'applet')->value('group_id');
|
||||
$list = [];
|
||||
if ($group_id) {
|
||||
$select = Db::name('system_group_data')->where('group_id', $group_id)->field('value')->limit(30)->where('status',1)->select();
|
||||
foreach ($select as $key => $value) {
|
||||
$list[] = json_decode($value['value'], true);
|
||||
}
|
||||
}
|
||||
return app('json')->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取省级行政区
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getProvince()
|
||||
{
|
||||
$select = Db::name('geo_province')->field('province_id id,province_code code,province_name name')->select();
|
||||
return app('json')->success($select);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取市级行政区
|
||||
* @param $code
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getCity($code)
|
||||
{
|
||||
$select = Db::name('geo_city')->where('province_code', $code)->field('city_id id,city_code code,city_name name')->select();
|
||||
return app('json')->success($select);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取县级行政区
|
||||
* @param $code
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getArea($code)
|
||||
{
|
||||
$select = Db::name('geo_area')->where('city_code', $code)->field('area_id id,area_code code,area_name name')->select();
|
||||
return app('json')->success($select);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取街道
|
||||
* @param $code
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getStreet($code)
|
||||
{
|
||||
$select = Db::name('geo_street')->where('area_code', $code)->field('street_id id,street_code code,street_name name')->select()->toArray();
|
||||
foreach ($select as $k => &$item) {
|
||||
$first_char = mb_str_split($item['name']);
|
||||
if ($first_char[0]) {
|
||||
$pinyin = new Pinyin();
|
||||
$string = $first_char[0];
|
||||
$pinyin = $pinyin->abbr($string);
|
||||
$item['pinyin'] = $pinyin;
|
||||
} else {
|
||||
$item['pinyin'] = '';
|
||||
}
|
||||
}
|
||||
return app('json')->success($select);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取社区
|
||||
* @param $code
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getVillage($code)
|
||||
{
|
||||
$select = Db::name('geo_village')->where('street_code', $code)->field('village_id id,village_code code,village_name name')->select();
|
||||
return app('json')->success($select);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,11 @@
|
||||
namespace app\controller\api\user;
|
||||
|
||||
|
||||
use app\common\dao\store\order\StoreOrderDao;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\model\user\User as UserModel;
|
||||
use app\common\repositories\store\IntegralRepository;
|
||||
use app\common\repositories\store\order\PresellOrderRepository;
|
||||
use app\common\repositories\store\service\StoreServiceRepository;
|
||||
use app\common\repositories\system\CacheRepository;
|
||||
use app\common\repositories\user\MemberinterestsRepository;
|
||||
@ -537,4 +541,38 @@ class User extends BaseController
|
||||
return app('json')->success('修改成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 邀请的商户记录
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function merchantRecord()
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$userIds = UserModel::where('spread_uid', $this->user->uid)->column('uid');
|
||||
$query = Merchant::whereIn('uid', $userIds)
|
||||
->where('status', 1)
|
||||
->where('is_del', 0)
|
||||
->where('mer_state', 1);
|
||||
$count = $query->count();
|
||||
$result = $query->page($page, $limit)
|
||||
->field('mer_id,mer_name,uid,real_name')
|
||||
->select()->toArray();
|
||||
$dao = new StoreOrderDao();
|
||||
/** @var PresellOrderRepository $preSellDao */
|
||||
$preSellRepo = app()->make(PresellOrderRepository::class);
|
||||
foreach ($result as &$item) {
|
||||
$saleOrderQuery = $dao->search(['mer_id' => $item['mer_id']])->whereIn('StoreOrder.status', [0, 1, 2, 3, 9, 10])->where('paid', 1);
|
||||
$saleOrderIds = $saleOrderQuery->column('order_id');
|
||||
$saleAmount1 = $saleOrderQuery->sum('StoreOrder.pay_price');
|
||||
$saleAmount2 = $preSellRepo->search(['paid' => 1, 'order_ids' => $saleOrderIds])->sum('pay_price');
|
||||
$item['sale_amount'] = bcadd($saleAmount1, $saleAmount2, 2);
|
||||
$item['buy_amount'] = StoreOrderOther::where('uid', $item['uid'])->whereIn('status', [0, 1, 2, 3, 9, 10])->where('paid', 1)->sum('pay_price');
|
||||
$item['buy_amount'] = bcadd($item['buy_amount'], 0, 2);
|
||||
}
|
||||
return app('json')->success(['count' => $count, 'list' => $result]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ use think\facade\Route;
|
||||
|
||||
Route::group('api/', function () {
|
||||
Route::any('test', 'api.Auth/test');
|
||||
Route::any('applet', 'api.Common/applet');
|
||||
//强制登录
|
||||
Route::group(function () {
|
||||
Route::group('v2', function () {
|
||||
@ -203,6 +204,7 @@ Route::group('api/', function () {
|
||||
Route::get('fields/info', 'UserFields/info');
|
||||
Route::post('fields/save', 'UserFields/save');
|
||||
Route::delete('fields/delete', 'UserFields/delete');
|
||||
Route::get('merchantRecord', 'User/merchantRecord');
|
||||
|
||||
})->prefix('api.user.');
|
||||
|
||||
@ -683,6 +685,11 @@ Route::group('api/', function () {
|
||||
Route::post('ajcheck', 'api.Auth/ajcheck');
|
||||
|
||||
Route::get('open_screen', 'api.Common/open_screen');
|
||||
Route::get('city/get_province', 'api.Common/getProvince');
|
||||
Route::get('city/get_city', 'api.Common/getCity');
|
||||
Route::get('city/get_area', 'api.Common/getArea');
|
||||
Route::get('city/get_street', 'api.Common/getStreet');
|
||||
Route::get('city/get_Village', 'api.Common/getVillage');
|
||||
})->middleware(AllowOriginMiddleware::class)
|
||||
->middleware(InstallMiddleware::class)
|
||||
->middleware(CheckSiteOpenMiddleware::class)
|
||||
|
Loading…
x
Reference in New Issue
Block a user