Merge pull request 'preview' (#76) from preview into master
Reviewed-on: #76
This commit is contained in:
commit
a50ee06864
@ -71,7 +71,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
$order_extend = [];
|
||||
//检查商品类型, 活动商品只能单独购买
|
||||
foreach ($merchantCartList as $merchantCart) {
|
||||
if($merchantCart['type_id']!=Merchant::TypeSupplyChain){
|
||||
|
||||
if(($merchantCart['type_id']!=Merchant::TypeSupplyChain)&&$address){
|
||||
if($merchantCart['street_id']!=$address['street_code']){
|
||||
throw new ValidateException('不支持跨区域购买,请在【我的】-【地址管理】更改后重新购买');
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1242,7 +1242,7 @@ class ProductRepository extends BaseRepository
|
||||
$append[] = 'topReply';
|
||||
}
|
||||
unset($res['attr'], $res['attrValue'], $res['oldAttrValue'], $res['seckillActive']);
|
||||
if (count($attr) > 0) {
|
||||
if (count($attr) > 1) {
|
||||
$firstSku = [];
|
||||
foreach ($attr as $item) {
|
||||
$firstSku[] = $item['attr_values'][0];
|
||||
|
@ -129,7 +129,7 @@ class SpuRepository extends BaseRepository
|
||||
* @author Qinii
|
||||
* @day 12/18/20
|
||||
*/
|
||||
public function getApiSearch($where, $page, $limit, $userInfo = null)
|
||||
public function getApiSearch($where, $page, $limit, $userInfo = null,$is_sku=false)
|
||||
{
|
||||
if (isset($where['keyword']) && !empty($where['keyword'])) {
|
||||
if (preg_match('/^(\/@[1-9]{1}).*\*\//', $where['keyword'])) {
|
||||
@ -154,7 +154,13 @@ class SpuRepository extends BaseRepository
|
||||
]);
|
||||
$productMake = app()->make(ProductRepository::class);
|
||||
$count = $query->fetchSql(false)->count();
|
||||
$list = $query->page($page, $limit)->setOption('field', [])->field($this->productFiled)->select();
|
||||
$list = $query->page($page, $limit)->setOption('field', [])->field($this->productFiled)->select()
|
||||
->each(function ($item) use ($is_sku,$productMake,$userInfo) {
|
||||
if($is_sku==true){
|
||||
$sku = $productMake->detailAttrValue($item['product']['attrValue'], $userInfo);
|
||||
$item['sku']=$sku;
|
||||
}
|
||||
});
|
||||
$append = ['stop_time','svip_price','show_svip_info','is_svip_price'];
|
||||
if ($productMake->getUserIsPromoter($userInfo))
|
||||
$append[] = 'max_extension';
|
||||
@ -177,7 +183,12 @@ class SpuRepository extends BaseRepository
|
||||
app()->make(UserVisitRepository::class)->searchProduct($this->userInfo ? $this->userInfo['uid'] : 0, $where['keyword'], (int)($where['mer_id'] ?? 0));
|
||||
}
|
||||
}
|
||||
$entryMerId = $where['entry_mer_id'] ?? '';
|
||||
unset($where['entry_mer_id']);
|
||||
$query = $this->dao->search($where);
|
||||
$count = $query->fetchSql(false)->count();
|
||||
if ($rand) {
|
||||
$query->whereRaw('spu_id >= ( SELECT floor( RAND() * ( SELECT MAX( spu_id ) FROM `eb_store_spu` ) ) )');
|
||||
// $dataKey = sprintf(CloudProduct::CacheKey, $where['mer_rand_id']);
|
||||
// $RedisCacheService = app()->make(RedisCacheService::class);
|
||||
// $exists = $RedisCacheService->exists($dataKey);
|
||||
@ -189,24 +200,20 @@ class SpuRepository extends BaseRepository
|
||||
// }
|
||||
// $where['product_id'] = $this->getSpuFromCache($where['mer_rand_id'], $page, $limit);
|
||||
// 查询
|
||||
$query = $this->dao->search($where);
|
||||
$randPidList = $query->setOption('field', [])->field(['P.product_id'])->fetchSql(false)->page(1)->limit(500)->column('P.product_id');
|
||||
$randNum = count($randPidList);
|
||||
// 最多10条随机数据
|
||||
if ($randNum > 10) {
|
||||
array_rand($randPidList, 10);
|
||||
} elseif ($randNum > 0) {
|
||||
array_rand($randPidList, $randNum);
|
||||
} else {
|
||||
$randPidList = [];
|
||||
}
|
||||
$where['product_id'] = $randPidList;
|
||||
unset($where['mer_rand_id'], $where['page']);
|
||||
// $query = $this->dao->search($where);
|
||||
// $randPidList = $query->setOption('field', [])->field(['P.product_id'])->fetchSql(false)->page(1)->limit(500)->column('P.product_id');
|
||||
// $randNum = count($randPidList);
|
||||
// // 最多10条随机数据
|
||||
// if ($randNum > 10) {
|
||||
// array_rand($randPidList, 10);
|
||||
// } elseif ($randNum > 0) {
|
||||
// array_rand($randPidList, $randNum);
|
||||
// } else {
|
||||
// $randPidList = [];
|
||||
// }
|
||||
// $where['product_id'] = $randPidList;
|
||||
// unset($where['mer_rand_id'], $where['page']);
|
||||
}
|
||||
$entryMerId = $where['entry_mer_id'] ?? '';
|
||||
unset($where['entry_mer_id']);
|
||||
$query = $this->dao->search($where);
|
||||
$count = $query->fetchSql(false)->count();
|
||||
$query->with([
|
||||
'merchant' => function ($query) {
|
||||
$query->field($this->merchantFiled)->with(['type_names']);
|
||||
|
@ -1,166 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\repositories\system\merchant;
|
||||
|
||||
use app\common\repositories\BaseRepository;
|
||||
use crmeb\jobs\SendSmsJob;
|
||||
use crmeb\services\SmsService;
|
||||
use FormBuilder\Factory\Elm;
|
||||
use app\common\dao\system\merchant\MerchantIntentionDao;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\facade\Queue;
|
||||
use think\facade\Route;
|
||||
|
||||
/**
|
||||
* @mixin MerchantIntentionDao
|
||||
*/
|
||||
class MerchantIntentionRepository extends BaseRepository
|
||||
{
|
||||
|
||||
public function __construct(MerchantIntentionDao $dao)
|
||||
{
|
||||
$this->dao = $dao;
|
||||
}
|
||||
|
||||
public function getList(array $where, $page, $limit)
|
||||
{
|
||||
$query = $this->dao->search($where);
|
||||
$count = $query->count();
|
||||
$list = $query->page($page, $limit)->order('create_time DESC , status ASC')->with(['merchantCategory', 'merchantType'])->select();
|
||||
|
||||
return compact('count', 'list');
|
||||
}
|
||||
|
||||
public function detail($id, ?int $uid)
|
||||
{
|
||||
$where = ['mer_intention_id' => $id];
|
||||
if (!is_null($uid)) {
|
||||
$where['uid'] = $uid;
|
||||
}
|
||||
return $this->dao->search($where)->find();
|
||||
}
|
||||
|
||||
public function updateIntention($id, array $data)
|
||||
{
|
||||
if ($this->dao->existsWhere(['mer_intention_id' => $id, 'status' => '1']))
|
||||
throw new ValidateException('当前状态不能修改');
|
||||
$data['images'] = implode(',', (array)$data['images']);
|
||||
$data['status'] = 0;
|
||||
$data['fail_msg'] = '';
|
||||
return $this->dao->update($id, $data);
|
||||
}
|
||||
|
||||
public function markForm($id)
|
||||
{
|
||||
$data = $this->dao->get($id);
|
||||
$form = Elm::createForm(Route::buildUrl('systemMerchantIntentionMark', ['id' => $id])->build());
|
||||
$form->setRule([
|
||||
Elm::textarea('mark', '备注', $data['remark'])->required(),
|
||||
]);
|
||||
return $form->setTitle('修改备注');
|
||||
}
|
||||
|
||||
public function statusForm($id)
|
||||
{
|
||||
$form = Elm::createForm(Route::buildUrl('systemMerchantIntentionStatus', ['id' => $id])->build());
|
||||
$form->setRule([
|
||||
Elm::select('status', '审核状态', 1)->options([
|
||||
['value' => 1, 'label' => '同意'],
|
||||
['value' => 2, 'label' => '拒绝'],
|
||||
])->control([
|
||||
[
|
||||
'value' => 1,
|
||||
'rule' => [
|
||||
Elm::radio('create_mer', '自动创建商户', 1)->options([
|
||||
['value' => 1, 'label' => '创建'],
|
||||
['value' => 2, 'label' => '不创建'],
|
||||
])
|
||||
]
|
||||
],
|
||||
[
|
||||
'value' => 2,
|
||||
'rule' => [
|
||||
Elm::textarea('fail_msg', '失败原因', '信息填写有误')
|
||||
]
|
||||
]
|
||||
]),
|
||||
]);
|
||||
return $form->setTitle('修改审核状态');
|
||||
}
|
||||
|
||||
public function updateStatus($id, $data)
|
||||
{
|
||||
$create = $data['create_mer'] == 1;
|
||||
unset($data['create_mer']);
|
||||
$intention = $this->search(['mer_intention_id' => $id])->find();
|
||||
if (!$intention)
|
||||
throw new ValidateException('信息不存在');
|
||||
if ($intention->status)
|
||||
throw new ValidateException('状态有误,修改失败');
|
||||
$config = systemConfig(['broadcast_room_type', 'broadcast_goods_type']);
|
||||
|
||||
$margin = app()->make(MerchantTypeRepository::class)->get($intention['mer_type_id']);
|
||||
$data['is_margin'] = $margin['is_margin'] ?? -1;
|
||||
$data['margin'] = $margin['margin'] ?? 0;
|
||||
$merData = [];
|
||||
if ($create) {
|
||||
$password = substr($intention['phone'], -6);
|
||||
$merData = [
|
||||
'mer_name' => $intention['mer_name'],
|
||||
'mer_phone' => $intention['phone'],
|
||||
'mer_account' => $intention['phone'],
|
||||
'category_id' => $intention['merchant_category_id'],
|
||||
'type_id' => $intention['mer_type_id'],
|
||||
'real_name' => $intention['name'],
|
||||
'status' => 1,
|
||||
'is_audit' => 1,
|
||||
'is_bro_room' => $config['broadcast_room_type'] == 1 ? 0 : 1,
|
||||
'is_bro_goods' => $config['broadcast_goods_type'] == 1 ? 0 : 1,
|
||||
'mer_password' => $password,
|
||||
'is_margin' => $margin['is_margin'] ?? -1,
|
||||
'margin' => $margin['margin'] ?? 0
|
||||
];
|
||||
$data['fail_msg'] = '';
|
||||
$smsData = [
|
||||
'date' => date('m月d日', strtotime($intention->create_time)),
|
||||
'mer' => $intention['mer_name'],
|
||||
'phone' => $intention['phone'],
|
||||
'pwd' => $password ?? '',
|
||||
'site_name' => systemConfig('site_name'),
|
||||
];
|
||||
}
|
||||
if ($data['status'] == 2) {
|
||||
$smsData = [
|
||||
'phone' => $intention['phone'],
|
||||
'date' => date('m月d日', strtotime($intention->create_time)),
|
||||
'mer' => $intention['mer_name'],
|
||||
'site' => systemConfig('site_name'),
|
||||
];
|
||||
}
|
||||
|
||||
Db::transaction(function () use ($config, $intention, $data, $create,$margin,$merData,$smsData) {
|
||||
if ($data['status'] == 1) {
|
||||
if ($create) {
|
||||
$merchant = app()->make(MerchantRepository::class)->createMerchant($merData);
|
||||
$data['mer_id'] = $merchant->mer_id;
|
||||
Queue::push(SendSmsJob::class, ['tempId' => 'APPLY_MER_SUCCESS', 'id' => $smsData]);
|
||||
}
|
||||
} else {
|
||||
Queue::push(SendSmsJob::class, ['tempId' => 'APPLY_MER_FAIL', 'id' => $smsData]);
|
||||
}
|
||||
$intention->save($data);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -293,7 +293,7 @@ class MerchantRepository extends BaseRepository
|
||||
*/
|
||||
public function getList($where, $page, $limit, $userInfo)
|
||||
{
|
||||
$field = 'mer_id,mini_banner,mer_name,mer_avatar,product_score,service_score,postage_score,sales,status,create_time,long,lat,mer_address,care_count,type_id,street_id,service_phone';
|
||||
$field = 'mer_id,mini_banner,mer_name,mer_avatar,product_score,service_score,postage_score,sales,status,create_time,long,lat,mer_address,care_count,type_id,street_id,service_phone,mer_info';
|
||||
$where['status'] = 1;
|
||||
$where['mer_state'] = 1;
|
||||
$where['is_del'] = 0;
|
||||
@ -317,7 +317,7 @@ class MerchantRepository extends BaseRepository
|
||||
$status = systemConfig('mer_location');
|
||||
/** @var MerchantTakeRepository $repository */
|
||||
$repository = app()->make(MerchantTakeRepository::class);
|
||||
$list = $query->with('street_names')->page($page, $limit)->setOption('field', [])->field($field)->select()
|
||||
$list = $query->with(['street_names','type_names'])->page($page, $limit)->setOption('field', [])->field($field)->select()
|
||||
->each(function ($item) use ($status, $where, $repository) {
|
||||
if ($status && $item['lat'] && $item['long'] && isset($where['location']['lat'], $where['location']['long'])) {
|
||||
$distance = getDistance($where['location']['lat'], $where['location']['long'], $item['lat'], $item['long']);
|
||||
@ -369,7 +369,7 @@ class MerchantRepository extends BaseRepository
|
||||
*/
|
||||
public function detail($id, $userInfo)
|
||||
{
|
||||
$merchant = $this->dao->apiGetOne($id)->hidden(['coordinates']);
|
||||
$merchant = $this->dao->apiGetOne($id);
|
||||
$merchant->append(['type_names', 'isset_certificate', 'services_type']);
|
||||
$merchant['care'] = false;
|
||||
if ($userInfo)
|
||||
|
@ -128,15 +128,15 @@ class ProductLibrary extends BaseController
|
||||
$data['stock'] = 9999999;
|
||||
$data['create_time'] = date('Y-m-d H:i:s');
|
||||
$data['images'] = '';
|
||||
$arr=[];
|
||||
if ($param['img'] != '') {
|
||||
$oss = $upload->to($dir)->stream(file_get_contents($param['img']));
|
||||
$data['image'] = $oss->filePath;
|
||||
|
||||
$arr[]=$oss->filePath;
|
||||
} else {
|
||||
$data['image'] = 'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230130/00ebcfdf75684f5494c0193075055d1.png';
|
||||
$data['slider_image'] = 'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230130/00ebcfdf75684f5494c0193075055d1.png';
|
||||
}
|
||||
$arr=[];
|
||||
foreach($param['imgList'] as $k=>$v){
|
||||
$oss=$upload->to($dir)->stream(file_get_contents($v));
|
||||
$arr[] = $oss->filePath;
|
||||
|
@ -1,300 +0,0 @@
|
||||
<?php
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\controller\admin\system\merchant;
|
||||
|
||||
|
||||
use app\common\repositories\store\product\ProductCopyRepository;
|
||||
use app\common\repositories\system\merchant\MerchantTypeRepository;
|
||||
use app\common\repositories\user\UserBillRepository;
|
||||
use crmeb\basic\BaseController;
|
||||
use app\common\repositories\system\merchant\MerchantAdminRepository;
|
||||
use app\common\repositories\system\merchant\MerchantCategoryRepository;
|
||||
use app\common\repositories\system\merchant\MerchantRepository;
|
||||
use app\validate\admin\MerchantValidate;
|
||||
use crmeb\jobs\ChangeMerchantStatusJob;
|
||||
use FormBuilder\Exception\FormBuilderException;
|
||||
use think\App;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\facade\Queue;
|
||||
|
||||
/**
|
||||
* Class Merchant
|
||||
* @package app\controller\admin\system\merchant
|
||||
* @author xaboy
|
||||
* @day 2020-04-16
|
||||
*/
|
||||
class Merchant extends BaseController
|
||||
{
|
||||
/**
|
||||
* @var MerchantRepository
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* Merchant constructor.
|
||||
* @param App $app
|
||||
* @param MerchantRepository $repository
|
||||
*/
|
||||
public function __construct(App $app, MerchantRepository $repository)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
public function count()
|
||||
{
|
||||
$where = $this->request->params(['keyword', 'date', 'status', 'statusTag', 'is_trader', 'category_id', 'type_id']);
|
||||
return app('json')->success($this->repository->count($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
* @author xaboy
|
||||
* @day 2020-04-16
|
||||
*/
|
||||
public function lst()
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$where = $this->request->params(['keyword', 'date', 'status', 'statusTag', 'is_trader', 'category_id', 'type_id']);
|
||||
return app('json')->success($this->repository->lst($where, $page, $limit));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @throws FormBuilderException
|
||||
* @author xaboy
|
||||
* @day 2020-04-16
|
||||
*/
|
||||
public function createForm()
|
||||
{
|
||||
return app('json')->success(formToData($this->repository->form()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MerchantValidate $validate
|
||||
* @param MerchantCategoryRepository $merchantCategoryRepository
|
||||
* @param MerchantAdminRepository $adminRepository
|
||||
* @return mixed
|
||||
* @author xaboy
|
||||
* @day 2020/7/2
|
||||
*/
|
||||
public function create(MerchantValidate $validate)
|
||||
{
|
||||
$data = $this->checkParam($validate);
|
||||
$this->repository->createMerchant($data);
|
||||
return app('json')->success('添加成功');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
* @throws FormBuilderException
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
* @author xaboy
|
||||
* @day 2020-04-16
|
||||
*/
|
||||
public function updateForm($id)
|
||||
{
|
||||
if (!$this->repository->exists($id))
|
||||
return app('json')->fail('数据不存在');
|
||||
|
||||
return app('json')->success(formToData($this->repository->updateForm($id)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param MerchantValidate $validate
|
||||
* @param MerchantCategoryRepository $merchantCategoryRepository
|
||||
* @return mixed
|
||||
* @throws DbException
|
||||
* @author xaboy
|
||||
* @day 2020-05-06
|
||||
*/
|
||||
public function update($id, MerchantValidate $validate, MerchantCategoryRepository $merchantCategoryRepository)
|
||||
{
|
||||
$data = $this->checkParam($validate, true);
|
||||
if (!$this->repository->exists($id))
|
||||
return app('json')->fail('数据不存在');
|
||||
if ($this->repository->fieldExists('mer_name', $data['mer_name'], $id))
|
||||
return app('json')->fail('商户名已存在');
|
||||
if ($data['mer_phone'] && isPhone($data['mer_phone']))
|
||||
return app('json')->fail('请输入正确的手机号');
|
||||
if (!$data['category_id'] || !$merchantCategoryRepository->exists($data['category_id']))
|
||||
return app('json')->fail('商户分类不存在');
|
||||
|
||||
unset($data['mer_account'], $data['mer_password']);
|
||||
$margin = $this->repository->checkMargin($id, $data['type_id']);
|
||||
$data['margin'] = $margin['margin'];
|
||||
$data['is_margin'] = $margin['is_margin'];
|
||||
$this->repository->update($id, $data);
|
||||
return app('json')->success('编辑成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
* @throws DbException
|
||||
* @author xaboy
|
||||
* @day 2020-04-17
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!$merchant = $this->repository->get(intval($id)))
|
||||
return app('json')->fail('数据不存在');
|
||||
if ($merchant->status)
|
||||
return app('json')->fail('请先关闭该商户');
|
||||
$this->repository->delete($id);
|
||||
return app('json')->success('编辑成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param MerchantValidate $validate
|
||||
* @param bool $isUpdate
|
||||
* @return array
|
||||
* @author xaboy
|
||||
* @day 2020-04-17
|
||||
*/
|
||||
public function checkParam(MerchantValidate $validate, $isUpdate = false)
|
||||
{
|
||||
$data = $this->request->params([['category_id', 0], ['type_id', 0], 'mer_name', 'commission_rate', 'real_name', 'mer_phone', 'mer_keyword', 'mer_address', 'mark', ['sort', 0], ['status', 0], ['is_audit', 0], ['is_best', 0], ['is_bro_goods', 0], ['is_bro_room', 0], ['is_trader', 0],'sub_mchid']);
|
||||
if (!$isUpdate) {
|
||||
$data += $this->request->params(['mer_account', 'mer_password']);
|
||||
}else {
|
||||
$validate->isUpdate();
|
||||
unset($data['status']);
|
||||
}
|
||||
$validate->check($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
* @throws DbException
|
||||
* @author xaboy
|
||||
* @day 2020-03-31
|
||||
*/
|
||||
public function switchStatus($id)
|
||||
{
|
||||
$is_best = $this->request->param('status', 0) == 1 ? 1 : 0;
|
||||
if (!$this->repository->exists($id))
|
||||
return app('json')->fail('数据不存在');
|
||||
$this->repository->update($id, compact('is_best'));
|
||||
return app('json')->success('修改成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
* @throws DbException
|
||||
* @author xaboy
|
||||
* @day 2020-03-31
|
||||
*/
|
||||
public function switchClose($id)
|
||||
{
|
||||
$status = $this->request->param('status', 0) == 1 ? 1 : 0;
|
||||
if (!$this->repository->exists($id))
|
||||
return app('json')->fail('数据不存在');
|
||||
$this->repository->update($id, compact('status'));
|
||||
Queue::push(ChangeMerchantStatusJob::class, $id);
|
||||
return app('json')->success('修改成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param MerchantAdminRepository $adminRepository
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
* @author xaboy
|
||||
* @day 2020/7/7
|
||||
*/
|
||||
public function login($id, MerchantAdminRepository $adminRepository)
|
||||
{
|
||||
if (!$this->repository->exists($id))
|
||||
return app('json')->fail('数据不存在');
|
||||
$adminInfo = $adminRepository->merIdByAdmin($id);
|
||||
$tokenInfo = $adminRepository->createToken($adminInfo);
|
||||
$admin = $adminInfo->toArray();
|
||||
unset($admin['pwd']);
|
||||
$data = [
|
||||
'token' => $tokenInfo['token'],
|
||||
'exp' => $tokenInfo['out'],
|
||||
'admin' => $admin,
|
||||
'url' => '/' . config('admin.merchant_prefix')
|
||||
];
|
||||
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO 修改复制次数表单
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @author Qinii
|
||||
* @day 2020-08-06
|
||||
*/
|
||||
public function changeCopyNumForm($id)
|
||||
{
|
||||
return app('json')->success(formToData($this->repository->copyForm($id)));
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO 修改复制次数
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @author Qinii
|
||||
* @day 2020-08-06
|
||||
*/
|
||||
public function changeCopyNum($id)
|
||||
{
|
||||
$data = $this->request->params(['type', 'num']);
|
||||
$num = $data['num'];
|
||||
if ($num <= 0) return app('json')->fail('次数必须为正整数');
|
||||
if ($data['type'] == 2) {
|
||||
$mer_num = $this->repository->getCopyNum($id);
|
||||
if (($mer_num - $num) < 0) return app('json')->fail('剩余次数不足');
|
||||
$num = '-' . $data['num'];
|
||||
}
|
||||
$arr = [
|
||||
'type' => 'sys',
|
||||
'num' => $num,
|
||||
'message' => '平台修改「' . $this->request->adminId() . '」',
|
||||
];
|
||||
app()->make(ProductCopyRepository::class)->add($arr, $id);
|
||||
return app('json')->success('修改成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO 清理删除的商户内容
|
||||
* @return \think\response\Json
|
||||
* @author Qinii
|
||||
* @day 5/15/21
|
||||
*/
|
||||
public function clearRedundancy()
|
||||
{
|
||||
$this->repository->clearRedundancy();
|
||||
return app('json')->success('清除完成');
|
||||
}
|
||||
}
|
@ -109,10 +109,11 @@ class Statistics extends BaseController
|
||||
if (isset($parmas['keyword']) && $parmas['keyword'] != '') {
|
||||
$where[] = ['store_name', 'like', '%' . $parmas['keyword'] . '%'];
|
||||
}
|
||||
$count=Db::name('store_product')->where($where)->count();
|
||||
$list = Db::name('store_product')->where($where)->page($parmas['page'])
|
||||
->field('product_id,store_name,image,price')
|
||||
->limit(10)->select();
|
||||
return app('json')->success(['page' => $parmas['page'], 'data' => $list]);
|
||||
return app('json')->success(['page' => $parmas['page'], 'data' => $list,'count'=>$count]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -127,7 +128,7 @@ class Statistics extends BaseController
|
||||
$where[] = ['p.source', '=', 200];
|
||||
break;
|
||||
case 300:
|
||||
$where[] = ['p.source', '=', 300];
|
||||
$where[] = ['p.source', '=', 0];
|
||||
break;
|
||||
default:
|
||||
return app('json')->fail('type:格式错误');
|
||||
@ -148,13 +149,13 @@ class Statistics extends BaseController
|
||||
if (!isset($parmas['goods_id']) || $parmas['goods_id'] == '') {
|
||||
return app('json')->fail('goods_id:格式错误');
|
||||
}
|
||||
|
||||
$mer_id=Db::name('merchant_intention')->where('mer_intention_id', $parmas['mer_intention_id'])->value('mer_id');
|
||||
$where[] = ['p.create_time', 'between time', [date("Y-m-d H:i:s", $parmas['start_time']), date("Y-m-d H:i:s", $parmas['end_time'])]];
|
||||
$where[] = ['p.product_id', 'in', explode(',', $parmas['goods_id'])];
|
||||
$where[] = ['p.is_refund', '=', 0];
|
||||
$count = Db::name('store_order_product')->alias('p')
|
||||
->where($where)
|
||||
->join('store_order o', 'o.mer_id=' . $parmas['mer_intention_id'] . ' and o.paid=1 and o.is_del=0')
|
||||
->join('store_order o', 'o.mer_id=' . $mer_id . ' and o.paid=1 and o.is_del=0')
|
||||
->sum('p.total_price');
|
||||
return app('json')->success(['procure_amount' => $count]);
|
||||
}
|
||||
@ -171,7 +172,7 @@ class Statistics extends BaseController
|
||||
$where[] = ['p.source', '=', 200];
|
||||
break;
|
||||
case 300:
|
||||
$where[] = ['p.source', '=', 300];
|
||||
$where[] = ['p.source', '=', 0];
|
||||
break;
|
||||
default:
|
||||
return app('json')->fail('type:格式错误');
|
||||
|
@ -16,6 +16,7 @@ use crmeb\basic\BaseController;
|
||||
use think\exception\HttpResponseException;
|
||||
use app\validate\admin\StoreCategoryValidate;
|
||||
use app\common\repositories\store\service\StoreServiceRepository;
|
||||
use think\facade\Db;
|
||||
|
||||
class StoreCategory extends BaseController
|
||||
{
|
||||
@ -167,4 +168,24 @@ class StoreCategory extends BaseController
|
||||
$validate->check($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分类
|
||||
*/
|
||||
public function list_level($pid=0,$level=0,$type=0){
|
||||
$where['pid']=$pid;
|
||||
$where['level']=$level;
|
||||
$where['is_show']=1;
|
||||
$where['mer_id']=0;
|
||||
if($type==0){
|
||||
$select= Db::name('store_category')->where($where)->field('store_category_id,pid,cate_name,sort,pic,is_show,is_hot')->select();
|
||||
}else{
|
||||
unset($where['pid']);
|
||||
$arr=$this->repository->getApiTwolist(0,1);
|
||||
|
||||
$select=formatCategory($arr,'store_category_id');
|
||||
}
|
||||
return app('json')->success($select);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -242,11 +242,6 @@ class Merchant extends BaseController
|
||||
if ($data['mer_state'] && !$merchant['sub_mchid'] && systemConfig('open_wx_combine'))
|
||||
return app('json')->fail('开启店铺前请先完成微信子商户入驻');
|
||||
}
|
||||
if($data['long']!=''&& $data['lat']!=''){
|
||||
$long=$data['long'];
|
||||
$lat=$data['lat'];
|
||||
Db::query("UPDATE eb_merchant SET coordinates = ST_GeomFromText('POINT($long $lat)') WHERE mer_id = $id");
|
||||
}
|
||||
Db::name('merchant')->where('mer_id',$id)->update($data);
|
||||
|
||||
Queue::push(ChangeMerchantStatusJob::class, $id);
|
||||
|
@ -257,7 +257,7 @@ class StoreCart extends BaseController
|
||||
*/
|
||||
public function checkParams(validate $validate)
|
||||
{
|
||||
$data = $this->request->params(['product_id','product_attr_unique','cart_num','is_new',['product_type',0],['group_buying_id',0],['spread_id',0], 'referer']);
|
||||
$data = $this->request->params(['product_id','product_attr_unique','cart_num','is_new',['product_type',0],['group_buying_id',0],['spread_id',0], 'referer',['source',2]]);
|
||||
$validate->check($data);
|
||||
if ($data['spread_id']) {
|
||||
if ($data['spread_id'] !== $this->request->userInfo()->uid){
|
||||
|
@ -111,7 +111,7 @@ class StoreOrderBehalf extends BaseController
|
||||
/**
|
||||
* 生成二维码
|
||||
*/
|
||||
public function logisticsCode($id)
|
||||
public function logisticsCode()
|
||||
{
|
||||
// $status = $this->request->param('status',1);
|
||||
$order_id = $this->request->param('order_id',0);
|
||||
@ -120,9 +120,9 @@ class StoreOrderBehalf extends BaseController
|
||||
if ($mer_id) {
|
||||
$order_id = Db::name('store_order_behalf')->where('mer_id', $mer_id)->where('status','>=',0)->where('order_id',$order_id)->value('order_id');
|
||||
if ($order_id) {
|
||||
$order = $this->repository->getWhere(['order_id' => $id,'is_del' => 0]);
|
||||
$order = $this->repository->getWhere(['order_id' => $order_id,'is_del' => 0]);
|
||||
|
||||
return app('json')->success(['qrcode' => $this->repository->logisticsQrcode($id, $order->order_sn)]);
|
||||
return app('json')->success(['qrcode' => $this->repository->logisticsQrcode($order_id, $order->order_sn)]);
|
||||
}
|
||||
}
|
||||
return app('json')->fail('信息有误:请联系官方人员');
|
||||
@ -138,11 +138,11 @@ class StoreOrderBehalf extends BaseController
|
||||
$uid = $this->request->userInfo()['uid'];
|
||||
$mer_id = Db::name('store_service')->where('uid', $uid)->where('is_del', 0)->value('mer_id');
|
||||
if ($mer_id) {
|
||||
$noPostage = Db::name('store_order_behalf')->where('mer_id', $mer_id)->where('status',0)
|
||||
->join('store_order', 'store_order.status = 0')
|
||||
$noPostage = Db::name('store_order_behalf')
|
||||
->where('mer_id', $mer_id)->where('status',0)
|
||||
->count();
|
||||
$noDeliver = Db::name('store_order_behalf')->where('mer_id', $mer_id)->where('status',1)
|
||||
->join('store_order', 'store_order.status = 1')
|
||||
$noDeliver = Db::name('store_order_behalf')
|
||||
->where('mer_id', $mer_id)->where('status',1)
|
||||
->count();
|
||||
|
||||
}
|
||||
|
@ -149,14 +149,13 @@ class CloudWarehouse extends BaseController
|
||||
if (empty($merchantIds)) {
|
||||
return app('json')->success(['count' => 0, 'list' => []]);
|
||||
}
|
||||
|
||||
$where['entry_mer_id'] = 0;
|
||||
$where['keyword'] = $params['keyword'];
|
||||
$where['mer_ids'] = $merchantIds;
|
||||
$where['product_type'] = $params['product_type'];
|
||||
$where['is_gift_bag'] = 0;
|
||||
$where['order'] = $params['order'] ?: 'sort';
|
||||
$products = $this->spuRepository->getApiSearch($where, $page, $limit, false);
|
||||
$products = $this->spuRepository->getApiSearch($where, $page, $limit, false,true);
|
||||
return app('json')->success($products);
|
||||
}
|
||||
}
|
||||
|
@ -61,14 +61,14 @@ class StoreSpu extends BaseController
|
||||
'type_id',
|
||||
'street_id'
|
||||
]);
|
||||
if($where['type_id']){
|
||||
$arr=['status' => 1, 'mer_state' => 1, 'is_del' => 0];
|
||||
if($where['street_id']){
|
||||
$arr['street_id']=$where['street_id'];
|
||||
if ($where['type_id']) {
|
||||
$arr = ['status' => 1, 'mer_state' => 1, 'is_del' => 0];
|
||||
if ($where['street_id']) {
|
||||
$arr['street_id'] = $where['street_id'];
|
||||
}
|
||||
$where['mer_ids'] = Merchant::getInstance()->whereIn('type_id', explode(',', $where['type_id']))->where($arr)->column('mer_id');
|
||||
}
|
||||
unset($where['type_id'],$where['street_id']);
|
||||
unset($where['type_id'], $where['street_id']);
|
||||
|
||||
$where['is_gift_bag'] = 0;
|
||||
$where['product_type'] = 0;
|
||||
@ -87,7 +87,7 @@ class StoreSpu extends BaseController
|
||||
public function streetLst($id)
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', Merchant::TypeCode['TypeCloudWarehouse'] . ',' .Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id');
|
||||
$typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', Merchant::TypeCode['TypeCloudWarehouse'] . ',' . Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id');
|
||||
$where = $this->request->params([
|
||||
'keyword',
|
||||
'cate_id',
|
||||
@ -150,18 +150,17 @@ class StoreSpu extends BaseController
|
||||
'keyword', 'cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid', 'mer_cate_id', ['product_type', 0], 'action', 'common'
|
||||
]);
|
||||
if ($where['action']) unset($where['product_type']);
|
||||
$currentMerchant = Db::name('merchant')->where('mer_id',$id)->field('category_id,street_id')->find();
|
||||
$currentMerchant = Db::name('merchant')->where('mer_id', $id)->field('category_id,street_id')->find();
|
||||
$typeIdArray = Db::name('MerchantType')->whereIn('type_code', (string)Merchant::TypeCode['TypeTownSupplyChain'])->column('mer_type_id');
|
||||
|
||||
|
||||
$merIdArray = Db::name('merchant')
|
||||
->where('street_id',$currentMerchant['street_id'])
|
||||
->where('mer_state',1)
|
||||
->where('status',1)
|
||||
->where('category_id',$currentMerchant['category_id'])
|
||||
->where('street_id', $currentMerchant['street_id'])
|
||||
->where('mer_state', 1)
|
||||
->where('status', 1)
|
||||
->where('category_id', $currentMerchant['category_id'])
|
||||
->whereIn('type_id', implode(',', $typeIdArray))
|
||||
->column('mer_id');
|
||||
$where['mer_array_id'] = $merIdArray;
|
||||
$where['mer_rand_id'] = $id;
|
||||
$where['entry_mer_id'] = $id;
|
||||
$where['is_gift_bag'] = 0;
|
||||
$where['order'] = $where['order'] ? $where['order'] : 'sort';
|
||||
@ -177,7 +176,7 @@ class StoreSpu extends BaseController
|
||||
public function recommend()
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$where = $this->request->params(['common','mer_id']);
|
||||
$where = $this->request->params(['common', 'mer_id']);
|
||||
$params = $this->request->params(['location']);
|
||||
// $typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', Merchant::TypeCode['TypeCloudWarehouse'] . ',' .Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id');
|
||||
$where['is_gift_bag'] = 0;
|
||||
@ -205,16 +204,20 @@ class StoreSpu extends BaseController
|
||||
}
|
||||
$where['product_type'] = 0;
|
||||
$where['is_stock'] = 1;
|
||||
if($params['location']!=''){
|
||||
[$lon,$lat]=explode(',',$params['location']);
|
||||
$select=Db::query("select mer_id,ST_Distance(coordinates, POINT($lon,$lat)) AS distance from eb_merchant where coordinates !='' and type_id IN ('10', '17') and is_del=0 and mer_state=1 ORDER BY distance LIMIT 100;");
|
||||
$arr=[];
|
||||
foreach($select as $k=>$v){
|
||||
$arr[]=$v['mer_id'];
|
||||
if ($params['location'] != '') {
|
||||
[$lng, $lat] = explode(',', $params['location']);
|
||||
$select = Db::name('merchant')->where('type_id', 'IN', ["10", "17"])->where(['is_del' => 0, 'mer_state' => 1])->whereNotNull('lat')->whereNotNull('long')->order(Db::raw("(2 * 6378.137 * ASIN(
|
||||
SQRT(
|
||||
POW( SIN( PI( ) * ( $lng- `long` ) / 360 ), 2 ) + COS( PI( ) * $lat / 180 ) * COS( `lat` * PI( ) / 180 ) * POW( SIN( PI( ) * ( $lat- `lat` ) / 360 ), 2 )
|
||||
)
|
||||
)
|
||||
) ASC "))->limit(50)->select();
|
||||
$arr = [];
|
||||
foreach ($select as $k => $v) {
|
||||
$arr[] = $v['mer_id'];
|
||||
}
|
||||
if($arr){
|
||||
$where['mer_ids'] =$arr;
|
||||
|
||||
if ($arr) {
|
||||
$where['mer_ids'] = $arr;
|
||||
}
|
||||
}
|
||||
$data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo);
|
||||
@ -230,7 +233,7 @@ class StoreSpu extends BaseController
|
||||
public function hot($type)
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$where = $this->request->params(['common','mer_id']);
|
||||
$where = $this->request->params(['common', 'mer_id']);
|
||||
$where['hot_type'] = $type;
|
||||
$where['is_gift_bag'] = 0;
|
||||
$where['order'] = 'star';
|
||||
@ -362,8 +365,8 @@ class StoreSpu extends BaseController
|
||||
|
||||
public function getHotRanking()
|
||||
{
|
||||
$cateId = $this->request->param('cate_pid',0);
|
||||
$cateId = is_array($cateId) ?:explode(',',$cateId);
|
||||
$cateId = $this->request->param('cate_pid', 0);
|
||||
$cateId = is_array($cateId) ?: explode(',', $cateId);
|
||||
$data = [];
|
||||
foreach ($cateId as $cate_id) {
|
||||
$cate = app()->make(StoreCategoryRepository::class)->get($cate_id);
|
||||
@ -378,7 +381,4 @@ class StoreSpu extends BaseController
|
||||
}
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
namespace app\controller\merchant\store\product;
|
||||
|
||||
use app\common\model\store\StoreCategory;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\repositories\store\order\StoreCartRepository;
|
||||
use app\common\repositories\store\product\ProductAttrValueRepository;
|
||||
@ -84,6 +85,11 @@ class Product extends BaseController
|
||||
{
|
||||
$params = $this->request->params($this->repository::CREATE_PARAMS);
|
||||
$data = $this->repository->checkParams($params,$this->request->merId());
|
||||
$cate_id=StoreCategory::where('pid',$data['cate_id'])->where('level',2)->value('store_category_id');
|
||||
if(!$cate_id){
|
||||
return app('json')->fail('请先添加第三级分类');
|
||||
}
|
||||
$data['cate_id']=$cate_id;
|
||||
$data['mer_id'] = $this->request->merId();
|
||||
if ($data['is_gift_bag'] && !$this->repository->checkMerchantBagNumber($data['mer_id']))
|
||||
return app('json')->fail('礼包数量超过数量限制');
|
||||
|
@ -16,7 +16,7 @@ class SendGoodsCode
|
||||
{
|
||||
$this->event = $event;
|
||||
Log::info("sendGoodsCode ============= handle监听order_id " . $this->event['order_id']);
|
||||
if ($this->event['activity_type'] == 0) {
|
||||
if ($this->event['activity_type'] == 0 || in_array($this->event['source'], [0,2,103])) {
|
||||
//发起物流信息返回快递员手机
|
||||
$logisticsPhone = $this->sendLogistics($this->event['order_id'], $this->event['order_sn']);
|
||||
//生成用户的收货码
|
||||
|
@ -30,7 +30,7 @@ class SendGoodsCodeJob implements JobInterface
|
||||
Log::info("sendGoodsCodeJob" . json_encode($this->event));
|
||||
Log::info("sendGoodsCodeJob ============= handle监听order_id " . $this->event['order_id']);
|
||||
try {
|
||||
if ($this->event['activity_type'] == 0) {
|
||||
if ($this->event['activity_type'] == 0 || in_array($this->event['source'], [0,2,103])) {
|
||||
//发起物流信息返回快递员手机
|
||||
$logisticsPhone = $this->sendLogistics($this->event['order_id'], $this->event['order_sn']);
|
||||
//生成用户的收货码
|
||||
|
@ -86,6 +86,18 @@ trait CategoresDao
|
||||
})->order('sort DESC,'.$this->getPk().' DESC')->select();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取二级分类
|
||||
* @param int $mer_id
|
||||
* @return mixed
|
||||
* @author Qinii
|
||||
*/
|
||||
public function getTwoAll($mer_id = 0,$status = null)
|
||||
{
|
||||
return $this->getModel()::getDB()->whereIn('level',[0,1])->where('mer_id', $mer_id)->when(($status !== null),function($query)use($status){
|
||||
$query->where($this->getStatus(),$status);
|
||||
})->order('sort DESC,'.$this->getPk().' DESC')->select();
|
||||
}
|
||||
/**
|
||||
* 通过id 获取path
|
||||
* @param int $id 需要检测的数据
|
||||
|
@ -37,7 +37,10 @@ trait CategoresRepository
|
||||
{
|
||||
return formatCategory($this->dao->getAll($merID,$status)->hidden(['path','level','mer_id','create_time'])->toArray(), $this->dao->getPk());
|
||||
}
|
||||
|
||||
public function getApiTwolist($merID,$status = null)
|
||||
{
|
||||
return formatCategory($this->dao->getTwoAll($merID,$status)->hidden(['path','level','mer_id','create_time'])->toArray(), $this->dao->getPk());
|
||||
}
|
||||
/**
|
||||
* 筛选用
|
||||
* @Author:Qinii
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
public/mer/js/chunk-c0ce761c.8de3cfca.js
Normal file
1
public/mer/js/chunk-c0ce761c.8de3cfca.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -35,6 +35,7 @@ Route::group('api/', function () {
|
||||
Route::get('region/goods', 'api.Auth/goodsStatistics');
|
||||
Route::get('global/config', 'api.Auth/globalConfig');
|
||||
Route::get('miniapp/version', 'api.Auth/miniAppVersion');
|
||||
Route::get('category/list_level', 'api.server.StoreCategory/list_level');
|
||||
Route::resource('upload', 'api.Upload');
|
||||
Route::post('articleCatch', 'api.Upload/article');
|
||||
//强制登录
|
||||
|
Loading…
x
Reference in New Issue
Block a user