Merge pull request 'dev' (#173) from dev into master

Reviewed-on: #173
This commit is contained in:
mkm 2024-03-11 11:03:20 +08:00
commit 0b8010872f
6 changed files with 63 additions and 9 deletions

View File

@ -5,6 +5,7 @@ namespace app\common\dao\store;
use app\common\dao\BaseDao;
use app\common\dao\store\consumption\StoreConsumptionUserDao;
use app\common\model\store\consumption\StoreConsumption;
use app\common\model\store\consumption\StoreConsumptionDetail;
use app\common\model\store\consumption\StoreConsumptionUser;
use app\common\model\store\StoreActivityOrder;
use app\common\model\store\StoreActivityUser;
@ -249,6 +250,34 @@ class StoreActivityUserDao extends BaseDao
return ['total_amount' => $totalAmount, 'count' => $count, 'record' => $record];
}
/**
* 红包获取记录
* @param int $userId
* @param int $type
* @param int $page
* @param int $limit
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function useRecord(int $userId, int $type, int $page, int $limit)
{
$totalAmount = StoreConsumptionUser::where('uid', $userId)
->whereIn('type', $type)
->where('status', StoreConsumptionUser::STATUS_UNUSED)
->sum('balance');
$query = StoreConsumptionDetail::field('create_time,order_id,amount coupon_price,pay_price')
->where('user_id', $userId)
->where('type', 1);
$count = $query->count();
$record = $query->page($page)->limit($limit)->select()->toArray();
foreach ($record as &$item) {
$item['order_amount'] = bcadd($item['coupon_price'], $item['pay_price'], 2);
}
return ['total_amount' => $totalAmount, 'count' => $count, 'record' => $record];
}
/**
* 红包余额统计
* @param int $userId

View File

@ -395,9 +395,6 @@ class Auth extends BaseController
$data['mer_info']['type_code'] = $merType['type_code'];
$data['mer_info']['type_name'] = $merType['type_name'];
$data['mer_info']['setting_status'] = 0;
if (($mer_arr['update_time'] ?? '') > ($mer_arr['create_time'] ?? '')) {
$data['mer_info']['setting_status'] = 1;
}
}
$data['fan_num'] = app()->make(RelevanceRepository::class)->getUserFans($user->uid, 1, 1, 1);
$data['focus_num'] = app()->make(RelevanceRepository::class)->getUserFocus($user->uid, 1, 1, 1);

View File

@ -80,7 +80,11 @@ class StoreOrder extends BaseController
$where['order_search'] = $this->request->param('search_info');
$where['mer_id'] = $merId;
$where['is_del'] = 0;
return app('json')->success($repository->merchantGetList($where, $page, $limit));
$result = $repository->merchantGetList($where, $page, $limit);
foreach ($result['list'] as &$item) {
$item['pay_price'] = $item['consumption_money'] > 0 ? bcadd($item['pay_price'], $item['consumption_money'], 2) : $item['pay_price'];
}
return app('json')->success($result);
}
public function order($merId, $id, StoreOrderRepository $repository)
@ -90,6 +94,7 @@ class StoreOrder extends BaseController
return app('json')->fail('订单不存在');
if ($detail['mer_id'] != $merId)
return app('json')->fail('没有权限');
$detail['pay_price'] = $detail['consumption_money'] > 0 ? bcadd($detail['pay_price'], $detail['consumption_money'], 2) : $detail['pay_price'];
return app('json')->success($detail->toArray());
}

View File

@ -133,4 +133,22 @@ class StoreActivity extends BaseController
return app('json')->success($result);
}
}
/**
* 红包获取记录
* @param StoreActivityUserDao $dao
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function useRecord(StoreActivityUserDao $dao)
{
$userId = $this->request->uid();
$type = $this->request->get('type', 1);
$page = $this->request->get('page', 1);
$limit = $this->request->get('limit', 10);
$result = $dao->useRecord($userId, $type, $page, $limit);
return app('json')->success($result);
}
}

View File

@ -122,7 +122,7 @@ class ExcelService
*/
public function order(array $where, int $page, int $limit)
{
$paytype = [0 => '余额', 1 => '微信', 2 => '小程序', 3 => 'H5', 4 => '支付宝', 5 => '支付宝扫码', 6 => '微信扫码',];
$paytype = [0 => '余额', 1 => '微信', 2 => '小程序', 3 => 'H5', 4 => '支付宝', 5 => '支付宝扫码', 6 => '微信扫码',8=>'信用购-先货后款',9=>'商户余额支付'];
$make = app()->make(StoreOrderRepository::class);
$status = $where['status'];
$del = $where['mer_id'] > 0 ? 0 : null;
@ -140,12 +140,14 @@ class ExcelService
$export = [];
foreach ($list as $item) {
$product = [];
foreach ($item['orderProduct'] as $value) {
$product[] = [
$value['cart_info']['product']['store_name'],
$value['cart_info']['product']['store_name']??'',
$value['cart_info']['productAttr']['sku'] ?: '无',
$value['product_num'] . ' ' . $value['unit_name'],
$value['cart_info']['productAttr']['price']
$value['product_num'] . ' ' . $value['unit_name']??'',
$value['cart_info']['productAttr']['price']??''
];
}
$one = [
@ -170,6 +172,8 @@ class ExcelService
];
$export[] = $one;
}
$header = ['商户名称', '订单编号', '订单类型', '推广人', '用户信息', '商品名称', '商品规格', '商品数量', '商品价格', '优惠', '实付邮费(元)', '实付金额(元)', '已退款金额(元)', '收货人', '收货人电话', '收货地址', '物流/电话', '下单时间', '支付方式', '支付状态', '商家备注'];
$filename = '订单列表_' . date('YmdHis');
$title = ['订单列表', '导出时间:' . date('Y-m-d H:i:s', time())];

View File

@ -476,6 +476,7 @@ Route::group('api/', function () {
Route::get('total', 'api.store.StoreActivity/total'); //活动红包统计
Route::get('product', 'api.store.StoreActivity/product'); //活动商品专区
Route::get('district', 'api.store.StoreActivity/district'); //活动地区列表
Route::get('useRecord', 'api.store.StoreActivity/useRecord'); //活动红包获取记录
});
})->middleware(UserTokenMiddleware::class, true);