添加:商户列表接口及推荐商品接口添加部分输出数据
This commit is contained in:
parent
dbd56251a9
commit
e43d510bfc
|
|
@ -10,12 +10,14 @@ use app\common\dao\store\product\ProductDao;
|
|||
use app\common\model\BaseModel;
|
||||
use app\common\model\store\coupon\StoreCouponProduct;
|
||||
use app\common\model\store\coupon\StoreCouponUser;
|
||||
use app\common\model\store\order\StoreOrder;
|
||||
use app\common\model\store\product\Product;
|
||||
use app\common\model\store\product\Spu;
|
||||
use app\common\model\store\service\StoreService;
|
||||
use app\common\model\system\config\SystemConfigValue;
|
||||
use app\common\model\system\financial\Financial;
|
||||
use app\common\model\system\serve\ServeOrder;
|
||||
use app\common\repositories\store\order\StoreOrderRepository;
|
||||
use app\common\repositories\store\StoreActivityRepository;
|
||||
|
||||
class Merchant extends BaseModel
|
||||
|
|
@ -75,7 +77,10 @@ class Merchant extends BaseModel
|
|||
{
|
||||
$list = Product::where('mer_id', $this['mer_id'])
|
||||
->where((new ProductDao())->productShow())
|
||||
->field('mer_id,product_id,store_name,image,price,is_show,status,is_gift_bag,is_good,cate_id')
|
||||
->with(['brand'=>function($query){
|
||||
$query->bind(['brand_name']);
|
||||
}])
|
||||
->field('mer_id,product_id,store_name,image,price,ot_price,is_show,status,is_gift_bag,is_good,cate_id,brand_id')
|
||||
->order('is_good DESC, sort DESC, create_time DESC')
|
||||
->limit(3)
|
||||
->select()->append(['show_svip_info']);
|
||||
|
|
@ -261,4 +266,25 @@ class Merchant extends BaseModel
|
|||
{
|
||||
$query->whereIn('mer_id',$value);
|
||||
}
|
||||
/**
|
||||
* Common: 获取本月销售数量
|
||||
* Author: wu-hui
|
||||
* Time: 2023/11/17 15:42
|
||||
* @return int
|
||||
*/
|
||||
public function getMonthSalesAttr(){
|
||||
$startTime = strtotime(date("Y-m-1 00:00:00"));// 本月1号0点
|
||||
$monthOrderCount = app()->make(StoreOrder::class)
|
||||
->where('mer_id',$this->mer_id)
|
||||
->where('pay_time','>=',date('Y/m/1 00:00:00', time()))
|
||||
->whereNotIn('status',[11,-1])
|
||||
->count();
|
||||
|
||||
return (int)$monthOrderCount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,8 +205,10 @@ class Merchant extends BaseController
|
|||
'sub_mchid',
|
||||
['commission_switch',0],
|
||||
['mer_integral_platform_rate',0],
|
||||
['mer_integral_merchant_rate',0]
|
||||
['avg_consumption',0],
|
||||
'mer_label',
|
||||
]);
|
||||
$data['mer_label'] = str_replace(',',',',$data['mer_label']);
|
||||
if (!$isUpdate) {
|
||||
$data += $this->request->params(['mer_account', 'mer_password']);
|
||||
}else {
|
||||
|
|
|
|||
|
|
@ -224,16 +224,44 @@ class Diy extends BaseController
|
|||
public function store(MerchantRepository $repository)
|
||||
{
|
||||
$limit = $this->request->param('limit',10);
|
||||
$data = $this->cache(function() use($repository,$limit) {
|
||||
$field = 'mer_id,care_count,is_trader,type_id,mer_banner,mini_banner,mer_name, mark,mer_avatar,product_score,service_score,postage_score,sales,status,is_best,create_time,long,lat,is_margin';
|
||||
$position = $this->request->param(['latitude','longitude']);
|
||||
// $data = $this->cache(function() use($repository,$limit,$position) {
|
||||
$field = 'mer_id,mer_address,mer_label,care_count,is_trader,type_id,category_id,mer_banner,mini_banner,mer_name, mark,mer_avatar,product_score,service_score,postage_score,sales,status,is_best,create_time,long,lat,is_margin,avg_consumption';
|
||||
$where['is_best'] = 1;
|
||||
$where['status'] = 1;
|
||||
$where['mer_state'] = 1;
|
||||
$where['is_del'] = 0;
|
||||
$list = $repository->search($where)->with(['type_name'])->setOption('field', [])->field($field)->limit($limit)->select()->append(['all_recommend']);
|
||||
if ($list) $data['list'] = $list->toArray();
|
||||
return $data;
|
||||
});
|
||||
$list = $repository->search($where)
|
||||
->with(['type_name','categoryName'])
|
||||
->setOption('field', [])
|
||||
->field($field)
|
||||
->limit($limit)
|
||||
->select()
|
||||
->append(['all_recommend','month_sales']);
|
||||
if ($list) {
|
||||
$data['list'] = $list->toArray();
|
||||
foreach($data['list'] as &$merInfo){
|
||||
$merInfo['distance'] = '';
|
||||
if ((float)$position['latitude'] > 0 && (float)$position['longitude'] > 0 && (float)$merInfo['lat'] > 0 && (float)$merInfo['long'] > 0) {
|
||||
$distance = getDistance((float)$position['latitude'], (float)$position['longitude'], (float)$merInfo['lat'], (float)$merInfo['long']);
|
||||
if ($distance < 0.9) {
|
||||
$distance = max(bcmul($distance, 1000, 0), 1).'m';
|
||||
if ($distance == '1m') {
|
||||
$distance = '100m以内';
|
||||
}
|
||||
} else {
|
||||
$distance .= 'km';
|
||||
}
|
||||
$merInfo['distance'] = $distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// return $data;
|
||||
// });
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue