1748153932 12 months ago
commit bd7be1d209
  1. 42
      app/command/dayValue.php
  2. 1
      app/common/repositories/store/StoreCategoryRepository.php
  3. 5
      app/common/repositories/store/order/StoreOrderCreateRepository.php
  4. 2
      app/common/repositories/store/order/StoreOrderRepository.php
  5. 32
      app/controller/admin/store/StoreBrand.php
  6. 2
      config/console.php
  7. 78
      config/partner.php
  8. 18
      crmeb/jobs/OrderPartnerJob.php
  9. 6
      route/admin/product.php

@ -0,0 +1,42 @@
<?php
declare (strict_types=1);
namespace app\command;
use Swoole\Coroutine\MySQL\Exception;
use think\console\Command;
use app\common\model\store\order\StoreOrderContribute;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use app\common\model\user\User as userModel;
use app\common\model\user\ValueContributionLog;
use app\common\model\store\product\Spu;
use app\common\model\store\order\StoreOrder;
use think\console\Output;
use think\event\RouteLoaded;
use think\exception\ValidateException;
use think\facade\Cache;
use think\facade\Db;
use think\facade\Route;
use app\common\repositories\system\auth\MenuRepository;
// /www/server/php/74/bin/php /server/wwwroot/crmeb/think dayValue
class dayValue extends Command
{
protected function configure()
{
// 指令配置
$this->setName('dayValue')
->addArgument('dayValue', Argument::OPTIONAL, 'php think menu [1] / [2]')
->setDescription('社区等级结算');
}
protected function execute(Input $input, Output $output)
{
}
}

@ -107,6 +107,7 @@ class StoreCategoryRepository extends BaseRepository
*/
public function getBrandList()
{
return app()->make(StoreBrandRepository::class)->getAll();
}

@ -1058,6 +1058,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
$rate = bcmul($merchantCart['merchantCategory']['commission_rate'], 100, 4);
}
$user_address = isset($address) ? ($address['province'] . $address['city'] . $address['district'] . $address['street'] . $address['detail']) : '';
//整理订单数据
$_order = [
'cartInfo' => $merchantCart,
@ -1093,9 +1094,9 @@ class StoreOrderCreateRepository extends StoreOrderRepository
'coupon_price' => bcadd($merchantCart['order']['coupon_price'], $merchantCart['order']['platform_coupon_price'], 2),
'platform_coupon_price' => $merchantCart['order']['platform_coupon_price'],
'pay_type' => $pay_type,
'user_address_id' => $user_address['address_id'] ?? 0,
'pay_image' => $pay_image ?? '',
'pay_type_2' => $pay_type_2 ?? ''
'pay_type_2' => $pay_type_2 ?? '',
'user_address_id' => $address['address_id'] ?? 0,
];
$allUseCoupon = array_merge($allUseCoupon, $merchantCart['order']['useCouponIds']);
$orderList[] = $_order;

@ -754,7 +754,7 @@ class StoreOrderRepository extends BaseRepository
$storeOrderStatusRepository->{$func}($orderStatus);
});
//推送到贡献值结算队列
Queue::push(OrderPartnerJob::class, compact('order'));
Queue::push(OrderPartnerJob::class, $order->toArray());
event('order.take', compact('order'));

@ -16,6 +16,7 @@ use think\App;
use crmeb\basic\BaseController;
use app\validate\admin\StoreBrandValidate as validate;
use app\common\repositories\store\StoreBrandRepository;
use app\common\repositories\store\CityAreaRepository;
class StoreBrand extends BaseController
{
@ -40,8 +41,8 @@ class StoreBrand extends BaseController
*/
public function lst()
{
[$page , $limit] = $this->getPage();
$where = $this->request->params(['brand_category_id','brand_name']);
[$page, $limit] = $this->getPage();
$where = $this->request->params(['brand_category_id', 'brand_name']);
return app('json')->success($this->repository->getList($where, $page, $limit));
}
@ -57,23 +58,23 @@ class StoreBrand extends BaseController
return app('json')->success('添加成功');
}
public function update($id,validate $validate)
public function update($id, validate $validate)
{
$data = $this->checkParams($validate);
if(!$this->repository->meExists($id))
if (!$this->repository->meExists($id))
return app('json')->fail('数据不存在');
if (!$this->repository->parentExists($data['brand_category_id']))
return app('json')->fail('上级分类不存在');
$this->repository->update($id,$data);
$this->repository->update($id, $data);
return app('json')->success('编辑成功');
}
public function delete($id)
{
if(!$this->repository->meExists($id))
if (!$this->repository->meExists($id))
return app('json')->fail('数据不存在');
if($this->repository->getBrandHasProduct($id))
if ($this->repository->getBrandHasProduct($id))
return app('json')->fail('该品牌下存在商品');
$this->repository->delete($id);
return app('json')->success('删除成功');
@ -85,16 +86,17 @@ class StoreBrand extends BaseController
return app('json')->fail('数据不存在');
return app('json')->success($this->repository->get($id));
}
/**
* 验证
* @param validate $validate
* @param validate $validate
* @param bool $isCreate
* @return array
* @author Qinii
*/
public function checkParams(validate $validate)
{
$data = $this->request->params(['brand_category_id','brand_name','is_show','sort','pic']);
$data = $this->request->params(['brand_category_id', 'brand_name', 'is_show', 'sort', 'pic']);
$validate->check($data);
return $data;
}
@ -137,4 +139,16 @@ class StoreBrand extends BaseController
$this->repository->update($id, ['is_show' => $status]);
return app('json')->success('修改成功');
}
public function all()
{
$data = $this->repository->getAll();
return app('json')->success($data);
}
public function getCitylist($id,CityAreaRepository $repository)
{
$where['parent_id'] = $id;
return app('json')->success($repository->getList($where));
}
}

@ -39,5 +39,7 @@ return [
'change:hotTop' => 'app\command\changeHotTop',
//各种积分转换
'brand' => 'app\command\brand',
//社区贡献值结算
'dayValue' => 'app\command\dayValue',
],
];

@ -16,21 +16,20 @@ return [
// 社区等级配置
'community_level' => [
[
'alias' => '星社区服务商 ',
'level_name' => 'S1',
'min_price' => '30000',
'alias' => '星社区服务商 ',
'level_name' => 'S7',
'min_price' => '100000000',
'pay_community' => '0.03',
],
[
'alias' => '二星社区服务商 ',
'level_name' => 'S2',
'min_price' => '300000',
], [
'alias' => '六星社区服务商 ',
'level_name' => 'S6',
'min_price' => '10000000',
'pay_community' => '0.03',
],
[
'alias' => '星社区服务商 ',
'level_name' => 'S3',
'min_price' => '100000',
'alias' => '星社区服务商 ',
'level_name' => 'S5',
'min_price' => '10000000',
'pay_community' => '0.03',
],
[
@ -38,46 +37,45 @@ return [
'level_name' => 'S4',
'min_price' => '3000000',
'pay_community' => '0.03',
],
[
'alias' => '五星社区服务商 ',
'level_name' => 'S5',
'min_price' => '10000000',
], [
'alias' => '三星社区服务商 ',
'level_name' => 'S3',
'min_price' => '100000',
'pay_community' => '0.03',
],
[
'alias' => '星社区服务商 ',
'level_name' => 'S6',
'min_price' => '10000000',
'alias' => '星社区服务商 ',
'level_name' => 'S2',
'min_price' => '300000',
'pay_community' => '0.03',
],
[
'alias' => '星社区服务商 ',
'level_name' => 'S7',
'min_price' => '100000000',
'alias' => '星社区服务商 ',
'level_name' => 'S1',
'min_price' => '30000',
'pay_community' => '0.03',
],
],
//品牌代理商等级配置
'brand_level' => [
[
'alias' => '品牌体验官',
'level_name' => 'B1',
'min_price' => '10000',
'alias' => '全球品牌代言人',
'level_name' => 'B7',
'min_price' => '1000000',
'pay_community' => '0.3',
'promotion_community' => '0.1'
],
[
'alias' => '品牌推荐官',
'level_name' => 'B2',
'min_price' => '30000',
'alias' => '亚太区品牌代言人',
'level_name' => 'B6',
'min_price' => '500000',
'pay_community' => '0.3',
'promotion_community' => '0.1'
],
[
'alias' => '品牌推广大使',
'level_name' => 'B3',
'min_price' => '50000',
'alias' => '中国区品牌代言人',
'level_name' => 'B5',
'min_price' => '300000',
'pay_community' => '0.3',
'promotion_community' => '0.1'
],
@ -89,23 +87,23 @@ return [
'promotion_community' => '0.1'
],
[
'alias' => '中国区品牌代言人',
'level_name' => 'B5',
'min_price' => '300000',
'alias' => '品牌推广大使',
'level_name' => 'B3',
'min_price' => '50000',
'pay_community' => '0.3',
'promotion_community' => '0.1'
],
[
'alias' => '亚太区品牌代言人',
'level_name' => 'B6',
'min_price' => '500000',
'alias' => '品牌推荐官',
'level_name' => 'B2',
'min_price' => '30000',
'pay_community' => '0.3',
'promotion_community' => '0.1'
],
[
'alias' => '全球品牌代言人',
'level_name' => 'B7',
'min_price' => '1000000',
'alias' => '品牌体验官',
'level_name' => 'B1',
'min_price' => '10000',
'pay_community' => '0.3',
'promotion_community' => '0.1'
],

@ -32,8 +32,9 @@ use app\common\repositories\user\UserAddressRepository;
class OrderPartnerJob implements JobInterface
{
public function fire($job,$data)
public function fire($job, $data)
{
file_put_contents('/tmp/debug_partner', '开始处理贡献值订单:'.var_export($data, 1), 8);
try {
//初始化贡献值
$bao_price = $mian_price = $ping_price = $total_price = 0;
@ -132,6 +133,8 @@ class OrderPartnerJob implements JobInterface
'street_id' => $address['street_id'] ?? '',
'created_time' => date('Y-m-d H:i:s'),
'baodan_liushui' => $bao_flowing,
'miandan_liushui' => $mian_flowing,
'ping_liushui' => $ping_flowing,
];
StoreOrderContribute::getDB()->insert($contribute_insert);
//订单角色贡献值-30%
@ -197,7 +200,7 @@ class OrderPartnerJob implements JobInterface
->select()->toArray();
$role_ids = array_column($trade_roles, 'id');
$trade_trade_data = array_column($trade_roles,null, 'id');
$trade_trade_data = array_column($trade_roles, null, 'id');
$user_list = User::getDB()->alias('u')
->leftJoin('UserPartner p', 'u.uid = p.uid')
->whereIn('p.partner_id', $role_ids)
@ -240,8 +243,8 @@ class OrderPartnerJob implements JobInterface
->whereIn('area_id', $area_ids)
->select()->toArray();
$role_ids = array_column($area_roles, 'id');
$trade_trade_data = array_column($area_roles, null,'id');
$role_ids = array_column($area_roles, 'id');
$trade_trade_data = array_column($area_roles, null, 'id');
$user_list = User::getDB()->alias('u')
->leftJoin('UserPartner p', 'u.uid = p.uid')
->whereIn('p.partner_id', $role_ids)
@ -275,8 +278,8 @@ class OrderPartnerJob implements JobInterface
->where('is_area', 0)
->where('status', 1)
->select()->toArray();
$role_ids = array_column($common_roles, 'id', );
$common_trade_data = array_column($common_roles, null,'id');
$role_ids = array_column($common_roles, 'id');
$common_trade_data = array_column($common_roles, null, 'id');
$user_list = User::getDB()->alias('u')
->leftJoin('UserPartner p', 'u.uid = p.uid')
->field('u.*,p.partner_id')
@ -284,7 +287,7 @@ class OrderPartnerJob implements JobInterface
->where('u.uid', '<>', $data['uid'])
->select();
if(!empty($user_list)){
if (!empty($user_list)) {
$user_list = $user_list->toArray();
$user_count = count($user_list);
foreach ($user_list as $cuk => $cuv) {
@ -310,6 +313,7 @@ class OrderPartnerJob implements JobInterface
//批量增加用户贡献值日志
ValueContributionLog::getDB()->insertAll($user_log_data);
//社区等级判断
echo 'ok';
} catch (\Exception $e) {
Log::info('订单角色贡献值处理失败; error : ' . $e->getMessage());

@ -150,6 +150,12 @@ Route::group(function () {
Route::get('lst', '/lst')->name('systemStoreBrandLst')->option([
'_alias' => '列表',
]);
Route::get('brandList', '/all')->name('systemStoreBrandAll')->option([
'_alias' => '列表',
]);
Route::get('city/:id', '/getCitylist')->name('systemStoreCity')->option([
'_alias' => '列表',
]);
Route::post('status/:id', '/switchStatus')->name('systemStoreBrandSwithStatus')->option([
'_alias' => '修改状态',
]);

Loading…
Cancel
Save