Wayne 11 months ago
commit b5cbc8b4f1
  1. 2
      app/api/controller/Dealer.php
  2. 14
      app/api/controller/Goods.php
  3. 53
      app/api/controller/User.php
  4. 39
      app/api/controller/dealer/Capital.php
  5. 13
      app/api/model/Goods.php
  6. 6
      app/api/model/Order.php
  7. 21
      app/api/model/dealer/Capital.php
  8. 10
      app/api/model/dealer/Order.php
  9. 2
      app/api/service/identity/PaySuccess.php
  10. 3
      app/api/service/order/Checkout.php
  11. 90
      app/command/CalDealerTime.php
  12. 8
      app/common.php
  13. 21
      app/common/model/Order.php
  14. 13
      app/common/model/OrderRefund.php
  15. 10
      app/store/model/Order.php
  16. 12
      app/store/model/OrderRefund.php
  17. 1
      app/store/model/User.php
  18. 1
      config/console.php

@ -61,7 +61,7 @@ class Dealer extends Controller
*/
public function center(): Json
{
$dealer = $this->dealer->toArray();
$dealer = isset($this->dealer) ? $this->dealer->toArray() : null;
$dealer['update_time'] = date("Y-m-d", strtotime($dealer['update_time']));

@ -18,7 +18,8 @@ use app\common\service\qrcode\Goods as GoodsPoster;
use cores\exception\BaseException;
use think\facade\Cache;
use think\response\Json;
use app\common\model\GoodsImage as GoodsImageModel;
use app\common\model\UploadFile as UploadFileModel;
/**
* 商品控制器
* Class Goods
@ -99,8 +100,15 @@ class Goods extends Controller
{
$param = $this->request->param();
$model = new GoodsModel;
$list = $model->presaleList($param);
$list = $model->presaleList($param)->toArray();
if (!$list) {
return $this->renderSuccess(compact('list'));
}
foreach ($list['data'] as $key => &$value) {
$goods_image = GoodsImageModel::where('goods_id', $value['goods_id'])->find();
$file_path = UploadFileModel::where('file_id', $goods_image['image_id'])->find();
$value['image'] = getUrl($file_path['file_path'], $file_path['domain']);
}
return $this->renderSuccess(compact('list'));
}

@ -14,6 +14,8 @@ namespace app\api\controller;
use app\api\model\Agreement as AgreementModel;
use app\api\model\User as UserModel;
use app\api\model\Invite\InviteLog;
use app\store\model\User as StoreUserModel;
use app\api\model\user\BalanceLog;
use app\api\model\user\GoodSource as GoodsSourceModel;
use app\api\model\user\InvoiceOrder;
@ -315,5 +317,56 @@ class User extends Controller
$Qrcode = new InviteUser($userInfo, 'MP-WEIXIN');
return $this->renderSuccess(['imageUrl' => $Qrcode->getImage()]);
}
/**
* 用户列表
* @return Json
* @throws \think\db\exception\DbException
*/
public function list(): Json
{
// 用户列表
$model = new StoreUserModel;
$list = $model->getList($this->request->param());
if (!$list) {
return $this->renderSuccess(compact('list'));
}
$list = $list->toArray();
// echo "<pre>";
// print_r($list);
// exit();
foreach ($list['data'] as $key => &$value) {
$log = InviteLog::where('invitee_user_id', $value['user_id'])->find();
$user = UserModel::where('user_id', $log['user_id'] ?? 0)->field('user_id,nick_name,mobile')->find();
$value['inviter'] = $user;
}
return $this->renderSuccess(compact('list'));
}
public function updateUser(): Json
{
$params = $this->request->param();
$user_id = $params['user_id'] ?? 0;
unset($params['user_id']);
UserModel::where('user_id', $user_id)->update($params);
return $this->renderSuccess('ok');
}
}

@ -0,0 +1,39 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\api\controller\dealer;
use think\response\Json;
use app\api\controller\Controller;
use app\api\model\dealer\Capital as CapitalModel;
/**
* 分销商佣金
* Class Order
* @package app\api\controller\user\dealer
*/
class Capital extends Controller
{
/**
* 分销商佣金列表
* @return Json
* @throws \cores\exception\BaseException
* @throws \think\db\exception\DbException
*/
public function list(): Json
{
// 分销商订单列表
$model = new CapitalModel;
$list = $model->getList($this->request->param(),$this->request->storeId());
return $this->renderSuccess(compact('list'));
}
}

@ -117,21 +117,22 @@ class Goods extends GoodsModel
return $this->setGoodsListDataFromApi($list);
}
public function presale()
public function presale($param)
{
$userId = UserService::getCurrentLoginUserId(true);
$info = PreSaleLog::where([
'user_id' => $userId,
'store_id' => request()->header()['storeid'],
'goods_id' => $_POST['goods_id'],
'goods_id' => $param['goods_id'] ?? 0,
])->find();
if (!$info) {
PreSaleLog::insert([
'user_id' => $userId,
'store_id' => request()->header()['storeid'],
'goods_id' => $_POST['goods_id'],
'pre_id' => $param['pre_id'] ?? 0,
'goods_id' => $param['goods_id'] ?? 0,
'ctime' => date('Y-m-d H:i:s')
]);
return true;
@ -224,7 +225,7 @@ class Goods extends GoodsModel
->where([
'a.store_id' => request()->header()['storeid'],
'a.user_id' => $userId,
])->field('c.goods_name,c.goods_price_min,a.id,b.p_time')->paginate(15);
])->field('c.goods_name,c.goods_price_min,a.id,b.p_time,c.goods_id')->paginate(15);
return $info;
}
@ -302,11 +303,11 @@ class Goods extends GoodsModel
return array_values($uniqueArray);
}
public function canlpresale()
public function canlpresale($param)
{
$userId = UserService::getCurrentLoginUserId(true);
$info = PreSaleLog::where([
'id' => $_POST['id'],
'id' => $param['id'],
'user_id' => $userId
])->delete();

@ -28,7 +28,7 @@ use app\common\enum\{OrderType,
use app\api\service\Store as StoreService;
use app\common\library\helper;
use cores\exception\BaseException;
use app\api\model\PreSaleLog;
/**
* 订单模型
* Class Order
@ -584,14 +584,14 @@ class Order extends OrderModel
$userId = UserService::getCurrentLoginUserId();
return [
'reservation_number' => RecoveryOrder::getCount(), // 上门预约待服务订单总数
'reservation_number' => PreSaleLog::where('user_id', $userId)->count(), // 上门预约待服务订单总数
'view_number' => GoodsBrowseLog::getCount(), // 浏览记录
'send_number' => TransferRecord::getCount(), // 发货数量
'integral_number' => User::get($userId)->points, // 积分数量
'coupon_number' => UserCoupon::getCount(), // 优惠券
'goods_collect_number' => 0, // 商品采集数量
'cart_number' => Cart::getCount(), // 购物车数量
'take_goods_number' => 0, // 发货记录&提货记录
'take_goods_number' => OrderModel::where('user_id', $userId)->where('delivery_type',20)->count(), // 发货记录&提货记录
];
}
}

@ -13,6 +13,7 @@ declare (strict_types=1);
namespace app\api\model\dealer;
use app\common\model\dealer\Capital as CapitalModel;
use app\api\service\User as UserService;
/**
* 分销商资金明细模型
@ -29,4 +30,24 @@ class Capital extends CapitalModel
'create_time',
'update_time',
];
/**
* 获取分销商佣金列表
* @param array $param
* @return \think\Paginator
* @throws \cores\exception\BaseException
* @throws \think\db\exception\DbException
*/
public function getList(array $param = [],int $storeId): \think\Paginator
{
// 当前用户ID
$userId = UserService::getCurrentLoginUserId();
// 获取分销商佣金列表
$list = $this->getNewQuery()
->where('user_id',$userId)
->where('store_id',$storeId)
->order(['create_time' => 'desc'])
->paginate(15);
return $list;
}
}

@ -21,6 +21,8 @@ use app\api\model\Order as OrderApiModel;
use app\common\enum\order\PayStatus as PayStatusEnum;
use app\common\model\UserAddress as UserAddessModel;
use cores\exception\BaseException;
use app\api\model\User as UserApiModel;
use app\common\enum\user\UserTypeEnum;
/**
@ -123,6 +125,14 @@ class Order extends DealerOrderModel
if (!$dealerUser['first_user_id']) {
return false;
}
//如果上级已经不是分销商
if(!User::isDealerUser($dealerUser['first_user_id'])){
return false;
}
//如果上级已经不是分销商
if(!UserApiModel::where('user_id',$dealerUser['first_user_id'])->value('user_type') !== UserTypeEnum::DEALER){
return false;
}
// 计算订单分销佣金
$capital = static::getCapitalByOrder($order);
// 保存分销订单记录

@ -382,6 +382,7 @@ class PaySuccess extends BaseService
if (!empty($userInfo['effective_time']) && strtotime($userInfo['effective_time']) > strtotime(date('Y-m-d'))) {
$time = $userInfo['effective_time'];
}
}
if (!User::isDealerUser($userInfo['user_id'])) {
// 新增分销商用户
@ -392,6 +393,7 @@ class PaySuccess extends BaseService
'mobile' => $mobile,
]);
}
$up['fx_effective_time'] = date("Y-m-d", strtotime("+{$orderInfo['month']} months", strtotime($time)));
}
$up['effective_time'] = date("Y-m-d", strtotime("+{$orderInfo['month']} months", strtotime($time)));
$userModel->where(['user_id' => $userInfo['user_id']])->save($up);

@ -850,6 +850,9 @@ class Checkout extends BaseService
'order_status' => OrderStatusEnum::NORMAL,
'platform' => getPlatform(),
'store_id' => $this->storeId,
'expect_receive_time' => $this->param['expect_receive_time'],//期待收货时间
'is_street_take' => $this->param['is_street_take'],//是否街边1-在 0-不在
'to_store_time' => $this->param['to_store_time'],//预计到店时间
];
if ($order['delivery'] == DeliveryTypeEnum::EXPRESS) {
$data['express_price'] = $order['expressPrice'];

@ -0,0 +1,90 @@
<?php
declare (strict_types=1);
namespace app\command;
use think\facade\Db;
use app\api\model\User;
use app\api\model\dealer\User as DealerUserModel;
use think\console\Input;
use think\console\Output;
use app\api\model\PreSale;
use think\console\Command;
use app\api\model\PreSaleLog;
use app\api\model\PreSaleMessage;
use app\api\model\{Goods as GoodsModel};
use app\common\enum\user\UserTypeEnum;
// /www/server/php/74/bin/php /server/wwwroot/yanzong/think CalDealerTime
class CalDealerTime extends Command
{
protected function configure()
{
// 指令配置
$this->setName('CalDealerTime')
->setDescription('自动计算分销时间');
}
protected function execute(Input $input, Output $output)
{
//todo wmc这边代码需要优化
//$list = User::where('status', 1)
$list = User::where('user_type', 'in', [UserTypeEnum::MEMBER,UserTypeEnum::DEALER])
->where('is_delete', '=', 0)
//->where('store_id',10001)
->select();
// print '<pre>';
// print_r($list->toArray());
// print '</pre>';
// die;
$del_fx_user_ids = [];
$del_hy_user_ids = [];
foreach ($list as $item) {
//如果分销商到期,改成会员;并且删除分销商
if(isset($item['fx_effective_time']) && strtotime($item['fx_effective_time']) <= strtotime(date('Y-m-d'))){
$del_fx_user_ids[] = $item['user_id'];
// User::where('user_id',$item['user_id'])->update([
// 'user_type'=>UserTypeEnum::MEMBER
// ]);
// //分销商表软删除
// DealerUserModel::where('user_id',$item['user_id'])->update(['is_delete'=>1]);
}
//如果会员到期,分销商到期了,改成普通用户
if((strtotime($item['effective_time']) <= strtotime(date('Y-m-d'))) && (isset($item['fx_effective_time']) && strtotime($item['fx_effective_time']) <= strtotime(date('Y-m-d')))){
$del_hy_user_ids[] = $item['user_id'];
// User::where('user_id',$item['user_id'])->update([
// 'user_type'=>UserTypeEnum::NORMAL
// ]);
}
//如果会员到期,分销商根本没有,改成普通用户
if((strtotime($item['effective_time']) <= strtotime(date('Y-m-d'))) && !isset($item['fx_effective_time'])){
$del_hy_user_ids[] = $item['user_id'];
// User::where('user_id',$item['user_id'])->update([
// 'user_type'=>UserTypeEnum::NORMAL
// ]);
}
}
//var_dump([$del_fx_user_ids, $del_hy_user_ids]);die;
Db::transaction(function () use ($del_fx_user_ids, $del_hy_user_ids) {
//如果分销商到期,改成会员;并且删除分销商
User::whereIn('user_id',$del_fx_user_ids)->update([
'user_type'=>UserTypeEnum::MEMBER
]);
//分销商表软删除
DealerUserModel::whereIn('user_id',$del_fx_user_ids)->update(['is_delete'=>1]);
//如果会员到期,分销商到期了/根本没有,改成普通用户
User::whereIn('user_id',$del_hy_user_ids)->update([
'user_type'=>UserTypeEnum::NORMAL
]);
});
}
}

@ -458,3 +458,11 @@ function getUrl($value, $host = ''){
return $value ? $host."/".$value : "";
}
function calc_time($startTime, $endTime) {
$diffTime = ($endTime - $startTime);
if ($diffTime > 3600) {
return "";
}
return date('i分钟s秒', (3600 - $diffTime));
}

@ -57,6 +57,8 @@ class Order extends BaseModel
'state_text', // 售后单状态文字描述
'pay_method_text', //订单支付方式文字描述
'delivery_type_text', //配送方式文字描述
'time_text', //倒计时文字
'store_phone'//商家电话
];
/**
@ -406,4 +408,23 @@ class Order extends BaseModel
{
return !empty(DeliveryType::data()[$data['delivery_type']])? DeliveryType::data()[$data['delivery_type']]['name']: '';//配送方式
}
public function getTimeTextAttr($value, $data) : int
{
$diffTime = 60*60*24;//24小时倒计时
// 付款状态
if ($data['pay_status'] == PayStatusEnum::PENDING) {
return (($data['create_time'] + $diffTime) - time()) * 1000;
}
// 收货状态
if ($data['receipt_status'] == ReceiptStatusEnum::NOT_RECEIVED) {
return (($data['delivery_time'] + $diffTime) - time()) * 1000;
}
return 0;
}
public function getStorePhoneAttr($value,$data) {
return Store::get($data['store_id'])->phone ?: '';
}
}

@ -12,6 +12,7 @@ declare (strict_types=1);
namespace app\common\model;
use app\common\enum\order\refund\RefundType;
use cores\BaseModel;
use think\model\relation\BelongsTo;
use think\model\relation\HasMany;
@ -30,6 +31,13 @@ class OrderRefund extends BaseModel
// 定义主键
protected $pk = 'order_refund_id';
/**
* 追加字段
*/
protected $append = [
'refund_type_text'
];
/**
* 关联用户表
* @return BelongsTo
@ -113,4 +121,9 @@ class OrderRefund extends BaseModel
{
return static::get($where, $with);
}
public function getRefundTypeTextAttr($value, $data): string
{
return !empty(RefundType::data()[$data['type']]) ? RefundType::data()[$data['type']]['name'] : '';
}
}

@ -105,6 +105,13 @@ class Order extends OrderModel
if(!UserService::isStore()) {
$filter[] = ['user.user_id' ,'=', UserService::getCurrentLoginUserId() ];
}
//普通会员和plus会员查询条件
if (!empty($param['user_id'])) {
$filter[] = ['user.user_id' ,'=', $param['user_id']];
}
if (!empty($param['delivery_type'])) {
$filter[] = ['order.delivery_type', '=', $param['delivery_type']];
}
$filterOr = [];
if (!empty($param['searchValue']) && $param['searchType'] == 'all') {
// $filterOr = [
@ -326,8 +333,7 @@ class Order extends OrderModel
*/
public function updateDelivery(array $data): bool
{
if ($this['pay_status'] != PayStatusEnum::SUCCESS
|| $this['delivery_status'] == DeliveryStatusEnum::DELIVERED || $this['delivery_type'] != 10) {
if ($this['delivery_status'] == DeliveryStatusEnum::DELIVERED || $this['delivery_type'] != 10) {
$this->error = "订单号[{$this['order_no']}]不满足修改条件!";
return false;
}

@ -77,6 +77,13 @@ class OrderRefund extends OrderRefundModel
if(!UserService::isStore()) {
$filter[] = ['user.user_id' ,'=', UserService::getCurrentLoginUserId() ];
}
//普通会员和plus会员查询条件
if (!empty($param['user_id'])) {
$filter[] = ['user.user_id' ,'=', $param['user_id']];
}
if (!empty($param['delivery_type'])) {
$filter[] = ['order.delivery_type', '=', $param['delivery_type']];
}
$filterOr = [];
if (!empty($param['searchValue']) && $param['searchType'] == 'all') {
// $filterOr = [
@ -104,12 +111,10 @@ class OrderRefund extends OrderRefundModel
$list = $query->order(['refund.create_time' => 'desc', 'refund.' . $this->getPk()])
->paginate(10);
// 加载关联订单数据
$list = static::preload($list, ['goods.image', 'orderData', 'user.avatar'], true);
$list = static::preload($list, ['goods.image', 'orderData', 'user.avatar','images.file'], true);
foreach ($list['data'] as $key => $row) {
$row['orderData']['pay_method_text'] = Method::data()[$row['orderData']['pay_method']]['name'];//支付方式
$row['orderData']['delivery_type_text'] = DeliveryType::data()[$row['orderData']['delivery_type']]['name'];//配送方式
// $row['orderData']['order_status'] = $row['orderData']['status'];
// unset($row['orderData']['status']);
$newRow = array_merge($row, $row['orderData']);
$list['data'][$key] = $newRow;
unset($list['data'][$key]['orderData']);
@ -160,6 +165,7 @@ class OrderRefund extends OrderRefundModel
}
// 起止时间
if (!empty($params['betweenTime'])) {
$params['betweenTime'] = explode(',', $params['betweenTime']);
$times = between_time($params['betweenTime']);
$filter[] = ['refund.create_time', '>=', $times['start_time']];
$filter[] = ['refund.create_time', '<', $times['end_time'] + 86400];

@ -111,6 +111,7 @@ class User extends UserModel
$filter = [];
// 会员昵称
!empty($params['search']) && $filter[] = ['nick_name|mobile', 'like', "%{$params['search']}%"];
!empty($params['user_type']) && $filter[] = ['user_type', 'in', explode(",", $params['user_type'])];
// 用户性别
$params['gender'] > -1 && $filter[] = ['gender', '=', (int)$params['gender']];
// 用户等级

@ -9,5 +9,6 @@ return [
'timer' => \app\timer\command\Timer::class,
//test脚本
'test' => 'app\command\test',
'CalDealerTime' => 'app\command\CalDealerTime',
],
];

Loading…
Cancel
Save