commit
8bf7568f8f
@ -315,4 +315,34 @@ class MerchantDao extends BaseDao
|
||||
return $this->getModel()::getInstance()->where($where);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按距离获取有效的商户
|
||||
* @param $lat
|
||||
* @param $lng
|
||||
* @param $sort 是否按距离排序
|
||||
* @param $distance 距离,单位米
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValidMerchantByDistance($lat, $lng, $sort = false, $distance = 2000)
|
||||
{
|
||||
$query = Merchant::where('type_id', 'IN', ["10", "17"])
|
||||
->where(['is_del' => 0, 'mer_state' => 1])
|
||||
->whereNotNull('lat')
|
||||
->whereNotNull('long')
|
||||
->field("mer_id,st_distance_sphere(point(`long`,`lat`), point({$lng}, {$lat})) as distance");
|
||||
if ($sort) {
|
||||
$query->order('distance')->limit(20);
|
||||
} else {
|
||||
$query->having("distance <= {$distance}")->limit(50);
|
||||
}
|
||||
$merchant = $query->select()->toArray();
|
||||
if (empty($merchant) && $distance < 5000 && !$sort) {
|
||||
$merchant = $this->getValidMerchantByDistance($lat, $lng, $sort, 5000);
|
||||
}
|
||||
if (!empty($merchant)) {
|
||||
return array_column($merchant, 'mer_id');
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -77,9 +77,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
//检查商品类型, 活动商品只能单独购买
|
||||
$allowDelivery = true;
|
||||
foreach ($merchantCartList as $merchantCart) {
|
||||
|
||||
if (($merchantCart['type_id'] != Merchant::TypeSupplyChain) && $address) {
|
||||
if ($merchantCart['street_id'] != $address['street_code']) {
|
||||
if ($merchantCart['street_id'] != $address['street_code'] && $createOrder && !in_array($merchantCart['mer_id'], $takes)) {
|
||||
throw new ValidateException('不支持跨区域购买,请在【我的】-【地址管理】更改后重新购买');
|
||||
}
|
||||
}
|
||||
|
@ -352,20 +352,22 @@ class StoreOrderRepository extends BaseRepository
|
||||
$merchantRepo->forceMargin = false;
|
||||
[$_payCityPrice, $finance, $increase] = $merchantRepo->autoMargin($_payPrice, $order, $finance, $financeSn, $i++);
|
||||
}
|
||||
$finance[] = [
|
||||
'order_id' => $order->order_id,
|
||||
'order_sn' => $order->order_sn,
|
||||
'user_info' => $groupOrder->user->nickname,
|
||||
'user_id' => $uid,
|
||||
'financial_type' => 'order_true',
|
||||
'financial_pm' => 0,
|
||||
'type' => 2,
|
||||
'number' => $_payCityPrice,
|
||||
'mer_id' => $product_mer_id,
|
||||
'financial_record_sn' => $financeSn . (($i++)+2)
|
||||
];
|
||||
if (!$is_combine) {
|
||||
app()->make(MerchantRepository::class)->addLockMoney($product_mer_id, 'order', $order->order_id, $_payCityPrice);
|
||||
if (isset($_payCityPrice)) {
|
||||
$finance[] = [
|
||||
'order_id' => $order->order_id,
|
||||
'order_sn' => $order->order_sn,
|
||||
'user_info' => $groupOrder->user->nickname,
|
||||
'user_id' => $uid,
|
||||
'financial_type' => 'order_true',
|
||||
'financial_pm' => 0,
|
||||
'type' => 2,
|
||||
'number' => $_payCityPrice,
|
||||
'mer_id' => $product_mer_id,
|
||||
'financial_record_sn' => $financeSn . (($i++)+2)
|
||||
];
|
||||
if (!$is_combine) {
|
||||
app()->make(MerchantRepository::class)->addLockMoney($product_mer_id, 'order', $order->order_id, $_payCityPrice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@ namespace app\common\repositories\store\product;
|
||||
use app\common\dao\store\order\StoreCartDao;
|
||||
use app\common\model\store\order\StoreOrder;
|
||||
use app\common\model\store\order\StoreOrderProduct;
|
||||
use app\common\model\store\product\CloudProduct;
|
||||
use app\common\model\store\product\ProductAttrValue;
|
||||
use app\common\model\store\product\ProductLabel;
|
||||
use app\common\model\store\product\PurchaseRecord;
|
||||
@ -1951,6 +1952,10 @@ class ProductRepository extends BaseRepository
|
||||
$product = $this->dao->search(null, $where)->find();
|
||||
|
||||
if (!$product) throw new ValidateException('商品已下架');
|
||||
if ($data['source'] == 103 && empty($product['old_product_id'])) {
|
||||
CloudProduct::where('product_id', $product['product_id'])->update(['status' => 0]);
|
||||
throw new ValidateException('商品已下架');
|
||||
}
|
||||
if ($product['type'] && !$data['is_new']) throw new ValidateException('虚拟商品不可加入购物车');
|
||||
$value_make = app()->make(ProductAttrValueRepository::class);
|
||||
$sku = $value_make->getOptionByUnique($data['product_attr_unique']);
|
||||
|
@ -30,73 +30,18 @@ use crmeb\jobs\ProductCopyJob;
|
||||
class Demo extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return app('json')->success('修改成功');
|
||||
$arr=Db::name('store_product')->whereIn('mer_id',[110,116,149,227,226,35,117,148,156,104,137,151,136,183,140,229,79,133,235])->where('status',1)->where('is_show',0)->field('product_id')->select();
|
||||
$mer_id=167;//导入到的商户
|
||||
$street_code=510521107;//导入到的商户
|
||||
$type_id=17;//导入到的商户分类
|
||||
$category_id=2566;//导入到的商户分类
|
||||
foreach($arr as $k=>$v){
|
||||
Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' =>$mer_id,'street_code'=>$street_code,'type_id'=>$type_id,'category_id'=>$category_id]);//短信通知
|
||||
}
|
||||
|
||||
|
||||
$mer_id=236;//导入到的商户
|
||||
$street_code=510521123;//导入到的商户
|
||||
foreach($arr as $k=>$v){
|
||||
Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' =>$mer_id,'street_code'=>$street_code,'type_id'=>$type_id,'category_id'=>$category_id]);//短信通知
|
||||
}
|
||||
|
||||
$mer_id=237;//导入到的商户
|
||||
$street_code=510521115;//导入到的商户
|
||||
|
||||
foreach($arr as $k=>$v){
|
||||
Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' =>$mer_id,'street_code'=>$street_code,'type_id'=>$type_id,'category_id'=>$category_id]);//短信通知
|
||||
}
|
||||
|
||||
$mer_id=238;//导入到的商户
|
||||
$street_code=510521105;//导入到的商户
|
||||
|
||||
foreach($arr as $k=>$v){
|
||||
Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' =>$mer_id,'street_code'=>$street_code,'type_id'=>$type_id,'category_id'=>$category_id]);//短信通知
|
||||
}
|
||||
|
||||
$mer_id=239;//导入到的商户
|
||||
$street_code=510521116;//导入到的商户
|
||||
|
||||
foreach($arr as $k=>$v){
|
||||
Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' =>$mer_id,'street_code'=>$street_code,'type_id'=>$type_id,'category_id'=>$category_id]);//短信通知
|
||||
}
|
||||
|
||||
//江阳
|
||||
$mer_id=31;//导入到的商户
|
||||
$street_code=510502108;//导入到的商户
|
||||
|
||||
foreach($arr as $k=>$v){
|
||||
Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' =>$mer_id,'street_code'=>$street_code,'type_id'=>$type_id,'category_id'=>$category_id]);//短信通知
|
||||
}
|
||||
|
||||
$mer_id=32;//导入到的商户
|
||||
$street_code=510502107;//导入到的商户
|
||||
|
||||
foreach($arr as $k=>$v){
|
||||
Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' =>$mer_id,'street_code'=>$street_code,'type_id'=>$type_id,'category_id'=>$category_id]);//短信通知
|
||||
}
|
||||
|
||||
$mer_id=118;//导入到的商户
|
||||
$street_code=510502106;//导入到的商户
|
||||
|
||||
foreach($arr as $k=>$v){
|
||||
Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' =>$mer_id,'street_code'=>$street_code,'type_id'=>$type_id,'category_id'=>$category_id]);//短信通知
|
||||
}
|
||||
|
||||
$mer_id=39;//导入到的商户
|
||||
$street_code=510502105;//导入到的商户
|
||||
|
||||
foreach($arr as $k=>$v){
|
||||
Queue::push(ProductCopyJob::class, ['product_id' => $v['product_id'], 'mer_id' =>$mer_id,'street_code'=>$street_code,'type_id'=>$type_id,'category_id'=>$category_id]);//短信通知
|
||||
{
|
||||
return app('json')->success('修改成功');
|
||||
//[31,32,118,39,167,236,237,238,239]
|
||||
// return app('json')->success('修改成功');>whereIn('mer_id',[110,116,149,227,226,35,117,148,156,104,137,151,136,183,140,229,79,133,235])->
|
||||
|
||||
$arr=Db::name('store_product')->whereIn('mer_id',[31,32,118,39,167,236,237,238,239])->where('is_show',1)->where('stock',0)->field('product_id')->select();
|
||||
foreach($arr as $item){
|
||||
|
||||
Queue::push(ProductCopyJob::class, ['product_id' => $item['product_id']]);//短信通知
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function transcoding($fileName)
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace app\controller\api\store\product;
|
||||
|
||||
use app\common\dao\system\merchant\MerchantDao;
|
||||
use app\common\model\store\GeoStreet;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\repositories\store\product\SpuRepository;
|
||||
use think\facade\Db;
|
||||
@ -45,18 +46,35 @@ class CloudWarehouse extends BaseController
|
||||
*/
|
||||
public function index($street_code, $page = 1, $category_id = 0, $cate_pid = 0,$cate_id = 0,$location = '')
|
||||
{
|
||||
$query = Db::name('cloud_product')->where('status', 1);
|
||||
if (!empty($location) && $location != ',') {
|
||||
[$lat, $lng] = explode(',', $location);
|
||||
}
|
||||
if (!empty($street_code) && (empty($location) || $location == ',')) {
|
||||
|
||||
$cloud_where['street_code']=$street_code;
|
||||
$cloud_where['status']=1;
|
||||
|
||||
$location = GeoStreet::where('street_code', $street_code)->field('lng,lat')->find();
|
||||
if (!empty($location)) {
|
||||
[$lat, $lng] = [$location['lat'], $location['lng']];
|
||||
}
|
||||
}
|
||||
if (!empty($lat)) {
|
||||
$merIds = (new MerchantDao())->getValidMerchantByDistance($lat, $lng);
|
||||
if (!empty($merIds)) {
|
||||
$query->whereIn('mer_id', $merIds);
|
||||
}
|
||||
}
|
||||
if (empty($merIds) && !empty($lat)) {
|
||||
$merIds = (new MerchantDao())->getValidMerchantByDistance($lat, $lng, true);
|
||||
$query->whereIn('mer_id', $merIds);
|
||||
}
|
||||
if($cate_pid!=0){
|
||||
$cate_id=Db::name('store_category')->where('pid',$cate_pid)->where('is_show',1)->column('store_category_id');
|
||||
}
|
||||
if($cate_id>0){
|
||||
$cloud_where['cate_id']=$cate_id;
|
||||
$query->whereIn('cate_id', $cate_id);
|
||||
}
|
||||
$cloud_product_arr = Db::name('cloud_product')
|
||||
->where($cloud_where)
|
||||
->where(function($query){
|
||||
$cloud_product_arr = $query->where(function($query){
|
||||
$query->whereOr('mer_labels', '')
|
||||
->whereOr('mer_labels',',5,');
|
||||
})->page($page)->field('product_id,mer_labels')->select();
|
||||
@ -75,9 +93,7 @@ class CloudWarehouse extends BaseController
|
||||
if (!$cloud_product) {
|
||||
return app('json')->success(['count' => 0, 'list' => []]);
|
||||
}
|
||||
$count = Db::name('cloud_product')
|
||||
->where($cloud_where)
|
||||
->where(function($query){
|
||||
$count = $query->where(function($query){
|
||||
$query->whereOr('mer_labels', '')
|
||||
->whereOr('mer_labels',',5,');
|
||||
})->count();
|
||||
@ -90,7 +106,7 @@ class CloudWarehouse extends BaseController
|
||||
if ($value['mer_labels'] == ',5,') {
|
||||
$list[$k]['mer_labels_name'] = '五日达';
|
||||
} else {
|
||||
$list[$k]['mer_labels_name'] = '次日达';
|
||||
$list[$k]['mer_labels_name'] = '同城';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,8 @@
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\api\store\product;
|
||||
|
||||
use app\common\dao\system\merchant\MerchantDao;
|
||||
use app\common\model\store\GeoStreet;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\repositories\store\product\ProductRepository;
|
||||
use app\common\repositories\store\StoreCategoryRepository;
|
||||
@ -62,23 +64,38 @@ class StoreSpu extends BaseController
|
||||
'street_id',
|
||||
'category_id',
|
||||
'type_code',
|
||||
'village_id'
|
||||
'village_id',
|
||||
'location'
|
||||
]);
|
||||
if ($where['type_id']||$where['type_code']) {
|
||||
$arr = ['status' => 1, 'mer_state' => 1, 'is_del' => 0];
|
||||
if ($where['street_id']) {
|
||||
$arr['street_id'] = $where['street_id'];
|
||||
$query = Merchant::where($arr);
|
||||
if ($where['location']) {
|
||||
[$lat, $lng] = explode(',', $where['location']);
|
||||
$merIds = (new MerchantDao())->getValidMerchantByDistance($lat, $lng);
|
||||
if (!empty($merIds)) {
|
||||
$query->whereIn('mer_id', $merIds);
|
||||
}
|
||||
}
|
||||
if ($where['street_id'] && empty($where['location'])) {
|
||||
$location = GeoStreet::where('street_code', $where['street_id'])->field('lng,lat')->find();
|
||||
if (!empty($location)) {
|
||||
$merIds = (new MerchantDao())->getValidMerchantByDistance($location['lat'], $location['lng']);
|
||||
if (!empty($merIds)) {
|
||||
$query->whereIn('mer_id', $merIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($where['village_id']) {
|
||||
$arr['village_id'] = $where['village_id'];
|
||||
$query->where('village_id', $where['village_id']);
|
||||
}
|
||||
if($where['type_code']){
|
||||
$mer_type_id=Db::name('merchant_type')->where('type_code',$where['type_code'])->value('mer_type_id');
|
||||
if($mer_type_id){
|
||||
$where['type_id'] = $mer_type_id;
|
||||
$query->where('type_id', $mer_type_id);
|
||||
}
|
||||
}
|
||||
$where['mer_ids'] = Merchant::getInstance()->whereIn('type_id', explode(',', $where['type_id']))->where($arr)->column('mer_id');
|
||||
$where['mer_ids'] = $query->whereIn('type_id', explode(',', $where['type_id']))->column('mer_id');
|
||||
}
|
||||
|
||||
unset($where['type_id'], $where['street_id'],$where['type_code'],$where['village_id']);
|
||||
|
@ -468,7 +468,7 @@ class Product extends BaseController
|
||||
if ($value['mer_labels'] == ',5,') {
|
||||
$select[$k]['mer_labels_name'] = '五日达';
|
||||
} else {
|
||||
$select[$k]['mer_labels_name'] = '次日达';
|
||||
$select[$k]['mer_labels_name'] = '同城';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,15 +16,26 @@ namespace crmeb\jobs;
|
||||
|
||||
use crmeb\interfaces\JobInterface;
|
||||
use app\controller\admin\store\StoreProduct;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 本地跑远程线程专门使用
|
||||
*/
|
||||
class ProductCopyJob implements JobInterface
|
||||
{
|
||||
|
||||
public function fire($job, $data)
|
||||
{
|
||||
$make = app()->make(StoreProduct::class);
|
||||
$make->copy($data['product_id'],$data['mer_id'],$data['street_code'],$data['type_id'],$data['category_id']);
|
||||
// $arrs= Db::name('store_product')->where('old_product_id',$data['product_id'])->select();
|
||||
// foreach($arrs as $it){
|
||||
// $res= Db::name('store_product')->where('product_id',$it['product_id'])->update(['is_del'=>1,'is_show'=>0,'is_used'=>0,'status'=>-2]);
|
||||
// if($res){
|
||||
// Db::name('cloud_product')->where('product_id',$it['product_id'])->delete();
|
||||
|
||||
// }
|
||||
// }
|
||||
// $make = app()->make(StoreProduct::class);
|
||||
// $make->copy($data['product_id'],$data['mer_id'],$data['street_code'],$data['type_id'],$data['category_id']);
|
||||
$job->delete();
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ class QrcodeService
|
||||
* @param $name
|
||||
* @return array|bool|string
|
||||
*/
|
||||
public function getQRCodePath($url, $name,$data)
|
||||
public function getQRCodePath($url, $name,$data = [])
|
||||
{
|
||||
if (!strlen(trim($url)) || !strlen(trim($name))) return false;
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user