Compare commits
No commits in common. "master" and "optimize" have entirely different histories.
@ -23,8 +23,6 @@ use think\exception\HttpResponseException;
|
||||
use think\exception\ValidateException;
|
||||
use think\Response;
|
||||
use Throwable;
|
||||
use Exception;
|
||||
use think\facade\Request;
|
||||
|
||||
/**
|
||||
* 应用异常处理类
|
||||
@ -52,22 +50,8 @@ class ExceptionHandle extends Handle
|
||||
*/
|
||||
public function report(Throwable $exception): void
|
||||
{
|
||||
$data = [
|
||||
'file' => $exception->getFile(),
|
||||
'line' => $exception->getLine(),
|
||||
'message' => $this->getMessage($exception),
|
||||
'code' => $this->getCode($exception),
|
||||
'http' =>Request::url()
|
||||
];
|
||||
$log = "[{$data['code']}]{$data['message']}[{$data['file']}:{$data['line']}]";
|
||||
if ($this->app->config->get('log.record_trace')) {
|
||||
$log .= PHP_EOL . $exception->getTraceAsString();
|
||||
}
|
||||
try {
|
||||
$this->app->log->record($log, 'error');
|
||||
} catch (Exception $e) {}
|
||||
// 使用内置的方式记录异常日志
|
||||
// parent::report($exception);
|
||||
parent::report($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,6 @@ 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;
|
||||
@ -85,44 +84,11 @@ class StoreActivityUserDao extends BaseDao
|
||||
return $data->value ?? 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 用下面的 default()
|
||||
* @param int $userId
|
||||
* @param int $activityId
|
||||
* @return StoreActivityUser|array|mixed|\think\Model|null
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getOne(int $userId, int $activityId = 1)
|
||||
{
|
||||
return StoreActivityUser::where('user_id', $userId)->where('activity_id', $activityId)->where('status', 1)->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户参加的活动类型,默认为消费返利
|
||||
* @param int $userId
|
||||
* @param int $activityId
|
||||
* @return StoreActivityUser|array|mixed|\think\Model|null
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function default(int $userId, int $activityId = 1)
|
||||
{
|
||||
$default = StoreActivityUser::where('user_id', $userId)->where('activity_id', $activityId)->where('status', 1)->find();
|
||||
if (empty($default)) {
|
||||
$couponId = StoreConsumption::where('type', StoreConsumption::TYPE_OWNER_CONSUMPTION)->value('coupon_id');
|
||||
$default = new StoreActivityUser();
|
||||
$default->user_id = $userId;
|
||||
$default->activity_id = $activityId;
|
||||
$default->value = $couponId;
|
||||
$default->status = 1;
|
||||
$default->save();
|
||||
}
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户参与活动的状态
|
||||
* @param int $userId 用户id
|
||||
@ -236,7 +202,6 @@ class StoreActivityUserDao extends BaseDao
|
||||
$query = UserBill::field('link_id,create_time,number coupon_price,mark')
|
||||
->where('uid', $userId)
|
||||
->where('category', 'red_pack')
|
||||
->where('status', 1)
|
||||
->where('type', "red_pack_{$type}");
|
||||
$count = $query->count();
|
||||
$record = $query->page($page)->limit($limit)->select()->toArray();
|
||||
@ -250,67 +215,37 @@ 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
|
||||
* @return array|array[]
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @return array
|
||||
*/
|
||||
public function total(int $userId)
|
||||
{
|
||||
$totalAmount = StoreConsumptionUser::where('uid', $userId)
|
||||
->whereIn('type', [StoreConsumptionUser::TYPE_ONE, StoreConsumptionUser::TYPE_TWO])
|
||||
->whereIn('status', [StoreConsumptionUser::STATUS_UNUSED, StoreConsumptionUser::STATUS_REPEAL])
|
||||
->field('balance,type')
|
||||
->where('status', StoreConsumptionUser::STATUS_UNUSED)
|
||||
->field('SUM(balance) as total_amount,type')
|
||||
->group('type')
|
||||
->select()->toArray();
|
||||
$totalAmount = reset_index($totalAmount, 'type');
|
||||
$result = [
|
||||
'1' => [
|
||||
[
|
||||
'type' => 1,
|
||||
'total_amount' => 0.00,
|
||||
'type_cn' => StoreConsumptionUser::TYPE_MAP[1],
|
||||
'total_amount' => 0.00
|
||||
],
|
||||
'2' => [
|
||||
[
|
||||
'type' => 2,
|
||||
'total_amount' => 0.00,
|
||||
'type_cn' => StoreConsumptionUser::TYPE_MAP[2],
|
||||
'total_amount' => 0.00
|
||||
]
|
||||
];
|
||||
foreach ($totalAmount as $item) {
|
||||
if (isset($result[$item['type']])) {
|
||||
$result[$item['type']]['total_amount']= bcadd($result[$item['type']]['total_amount'], $item['balance'], 2);
|
||||
foreach ($result as &$item) {
|
||||
if (isset($totalAmount[$item['type']])) {
|
||||
$item['total_amount'] = $totalAmount[$item['type']]['total_amount'];
|
||||
}
|
||||
$item['type_cn'] = StoreConsumptionUser::TYPE_MAP[$item['type']];
|
||||
}
|
||||
return array_values($result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ use app\common\model\store\order\StoreOrder;
|
||||
use app\common\model\system\merchant\FinancialRecord;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserBill;
|
||||
use app\common\repositories\system\merchant\MerchantRepository;
|
||||
use crmeb\utils\Curl;
|
||||
use think\facade\Log;
|
||||
@ -28,14 +27,6 @@ class CommissionDao
|
||||
*/
|
||||
public function firstOrderCommission($order, $financeDao)
|
||||
{
|
||||
$commission = bcmul($order['pay_price'], 0.01, 2);
|
||||
if ($commission > 0 && $order['order_type'] == 1) {
|
||||
// 订单为自提,且佣金大于0
|
||||
$financeDao->user = $order->user;
|
||||
$financeDao->order = $order;
|
||||
$financeDao->platformOut($commission, 'commission_to_store', $order['mer_id']);
|
||||
app()->make(MerchantRepository::class)->addLockMoney($order['mer_id'], 'order', $order['order_id'], $commission);
|
||||
}
|
||||
$consumption = StoreConsumption::where('status', 1)->where('type', StoreConsumption::TYPE_FIRST_ORDER_COMMISSION)->find();
|
||||
if (empty($consumption)) {
|
||||
return $financeDao;
|
||||
@ -45,6 +36,14 @@ class CommissionDao
|
||||
if (!$isFirstOrder) {
|
||||
return $financeDao;
|
||||
}
|
||||
$commission = bcmul($order['pay_price'], 0.01, 2);
|
||||
if ($commission > 0 && $order['order_type'] == 1) {
|
||||
// 订单为自提,且佣金大于0
|
||||
$financeDao->user = $order->user;
|
||||
$financeDao->order = $order;
|
||||
$financeDao->platformOut($commission, 'first_order_commission');
|
||||
app()->make(MerchantRepository::class)->addLockMoney($order['mer_id'], 'order', $order['order_id'], $commission);
|
||||
}
|
||||
// 给镇合伙人、村合伙人、小组服务团队、店铺分佣,仅直推
|
||||
$promotionCode = User::where('uid', $order['uid'])->value('promotion_code');
|
||||
if (!empty($promotionCode)) {
|
||||
@ -55,8 +54,8 @@ class CommissionDao
|
||||
$commission = bcmul($order['pay_price'], 0.03, 2);
|
||||
$financeDao->user = $user;
|
||||
$financeDao->order = $order;
|
||||
$financeDao->platformOut($commission, 'commission_to_promoter', $merchantId);
|
||||
app()->make(MerchantRepository::class)->addLockMoney($merchantId, 'order', $order['order_id'], $commission);
|
||||
$financeDao->platformOut($commission, 'first_order_commission');
|
||||
app()->make(MerchantRepository::class)->addLockMoney($order['mer_id'], 'order', $order['order_id'], $commission);
|
||||
$redPack = bcmul($order['pay_price'], $consumption['config']['red_pack_rate'], 2);
|
||||
if ($redPack > 0) {
|
||||
try {
|
||||
@ -98,7 +97,7 @@ class CommissionDao
|
||||
if ($commission > 0) {
|
||||
$financeDao->user = $user;
|
||||
$financeDao->order = $order;
|
||||
$financialType = $user['type'] == 4 ? 'commission_to_courier' : 'commission_to_promoter';
|
||||
$financialType = $user['type'] == 3 ? 'order_commission' : 'first_order_commission'; // TODO 配送员的佣金类型需要调整
|
||||
$financeDao->platformOut($commission, $financialType);
|
||||
$result[] = $user;
|
||||
}
|
||||
@ -143,7 +142,9 @@ class CommissionDao
|
||||
$url = env('task.new_worker_host_url') . '/api/shop_call/' . $api;
|
||||
$result = $curl->post($url, ['timestamp' => $timestamp, 'data' => $encrypt]);
|
||||
$result = json_decode($result, true);
|
||||
Log::info('供销佣金:' . var_export($result, true));
|
||||
if ($result['code'] != 1) {
|
||||
Log::error('发送佣金失败:' . var_export($result, true));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -155,39 +156,39 @@ class CommissionDao
|
||||
{
|
||||
// 是否已经退过佣金
|
||||
$refunded = FinancialRecord::where('order_id', $refundOrder->order['order_id'])
|
||||
->whereIn('financial_type', ['commission_to_store_refund', 'commission_to_courier_refund', 'commission_to_promoter_refund'])
|
||||
->whereIn('financial_type', ['order_commission_refund', 'first_order_commission_refund'])
|
||||
->count();
|
||||
if ($refunded > 0) {
|
||||
return;
|
||||
}
|
||||
// 退佣金和红包、保证金
|
||||
$commission = bcmul($refundOrder->order['pay_price'], 0.01, 2);
|
||||
$financeDao = new FinancialDao();
|
||||
if ($commission > 0 && $refundOrder->order['order_type'] == 1 && $refundOrder->order['source'] != 105) {
|
||||
// 订单为自提,且佣金大于0,下单的店铺退佣金
|
||||
$financeDao->user = $refundOrder->order->user;
|
||||
$financeDao->order = $refundOrder->order;
|
||||
$financeDao->platformIn($commission, 'first_order_commission_refund');
|
||||
app()->make(MerchantRepository::class)->subLockMoney($refundOrder->order['mer_id'], 'order', $refundOrder->order['order_id'], $commission);
|
||||
}
|
||||
|
||||
// 退佣金和红包
|
||||
$financeRecord = FinancialRecord::where('order_id', $refundOrder->order['order_id'])
|
||||
->whereIn('financial_type', ['commission_to_store', 'commission_to_courier', 'commission_to_promoter'])
|
||||
->field('user_id uid,user_info nickname,number,mer_id,financial_type')->select()->toArray();
|
||||
->whereIn('financial_type', ['order_commission', 'first_order_commission'])
|
||||
->field('user_id uid,user_info nickname')->select()->toArray();
|
||||
if (empty($financeRecord)) {
|
||||
return;
|
||||
}
|
||||
$userIds = [];
|
||||
$financeDao = new FinancialDao();
|
||||
$redPack = bcmul($refundOrder->order['pay_price'], 0.07, 2);
|
||||
foreach ($financeRecord as $item) {
|
||||
$userIds[] = $item['uid'];
|
||||
$financeDao->user = $item;
|
||||
$financeDao->order = $refundOrder->order;
|
||||
$financeDao->platformIn($item['number'], $item['financial_type'] . '_refund', $item['mer_id']);
|
||||
if ($item['mer_id'] > 0) {
|
||||
app()->make(MerchantRepository::class)->subLockMoney($item['mer_id'], 'order', $refundOrder->order['order_id'], $item['number']);
|
||||
}
|
||||
$financeDao->platformIn($item['number'], $item['financial_type'] . '_refund');
|
||||
(new StoreConsumptionUserDao())->refundByCommission($item['uid'], $refundOrder->order->order_id, $redPack);
|
||||
}
|
||||
$financeDao->save();
|
||||
|
||||
// 服务团队退红包
|
||||
$redPacks = UserBill::whereIn('uid', $userIds)->where('extra->order_id',$refundOrder->order['order_id'])->select()->toArray();
|
||||
foreach ($redPacks as $redPack) {
|
||||
(new StoreConsumptionUserDao())->refundByCommission($redPack['uid'], $refundOrder->order['order_id'], $redPack['number']);
|
||||
}
|
||||
|
||||
$promotionCode = User::where('uid', $refundOrder['uid'])->value('promotion_code');
|
||||
if ($promotionCode && strpos($promotionCode, 'mer_') === false){
|
||||
if ($promotionCode) {
|
||||
$curl = new Curl();
|
||||
$aes = new \AES();
|
||||
$timestamp = time();
|
||||
@ -197,7 +198,9 @@ class CommissionDao
|
||||
$url = env('task.new_worker_host_url') . '/api/shop_call/handleRefund';
|
||||
$result = $curl->post($url, ['timestamp' => $timestamp, 'data' => $encrypt]);
|
||||
$result = json_decode($result, true);
|
||||
Log::error('发起佣金退款:' . var_export($result, true));
|
||||
if ($result['code'] != 1) {
|
||||
Log::error('发起佣金退款失败:' . var_export($result, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ class StoreConsumptionDao extends BaseDao
|
||||
{
|
||||
return StoreConsumption::whereIn('type', [StoreConsumption::TYPE_OWNER_CONSUMPTION, StoreConsumption::TYPE_PULL_CONSUMPTION])->where('status', StoreConsumption::STATUS_ENABLE)
|
||||
->field('coupon_id,start_time,end_time,title')->select()->each(function ($item){
|
||||
if($item['title']=='无门槛实物通用补贴'){
|
||||
if($item['title']=='无门槛实物通用红包'){
|
||||
$item['title'] = '用户推荐拉新活动';
|
||||
}else{
|
||||
$item['title'] = '用户消费补贴活动';
|
||||
|
@ -5,7 +5,6 @@ namespace app\common\dao\store\consumption;
|
||||
use app\common\dao\BaseDao;
|
||||
use app\common\dao\store\StoreActivityOrderDao;
|
||||
use app\common\dao\store\StoreActivityUserDao;
|
||||
use app\common\dao\system\financial\FinancialDao;
|
||||
use app\common\model\store\consumption\StoreConsumption;
|
||||
use app\common\model\store\consumption\StoreConsumptionUser;
|
||||
use app\common\model\store\order\StoreGroupOrder;
|
||||
@ -42,17 +41,6 @@ class StoreConsumptionUserDao extends BaseDao
|
||||
|
||||
/** @var float $consumptionTotalAmount 红包总金额 */
|
||||
public $consumptionTotalAmount;
|
||||
/** @var int $orderType 订单类型:1 groupOrder,2 order */
|
||||
public $orderType = 2;
|
||||
/** @var float $consumptionUsed 已使用的红包金额 */
|
||||
public $consumptionUsed;
|
||||
/** @var float $profitRate 商品毛利率 */
|
||||
public $profitRate;
|
||||
|
||||
public $startTime;
|
||||
public $endTime;
|
||||
public $billExtra;
|
||||
public $onlyBill = false; // 是否只写入用户账单
|
||||
|
||||
protected function getModel(): string
|
||||
{
|
||||
@ -91,7 +79,7 @@ class StoreConsumptionUserDao extends BaseDao
|
||||
*/
|
||||
public function promoter(int $userId, $groupOrder, int $spreadUserId)
|
||||
{
|
||||
$activityUser = (new StoreActivityUserDao())->default($userId);
|
||||
$activityUser = (new StoreActivityUserDao())->getOne($userId);
|
||||
$consumption = (new StoreConsumptionDao())->getOne($activityUser['value'] ?? 0);
|
||||
//用户没有参加 消费金活动 或 已超过任务完成时间
|
||||
$endTime = $this->getEndTime($activityUser['create_time'] ?? '2024-01-01 00:00:00');
|
||||
@ -110,7 +98,6 @@ class StoreConsumptionUserDao extends BaseDao
|
||||
$storeActivityOrderDao = new StoreActivityOrderDao();
|
||||
$storeActivityOrder = $storeActivityOrderDao->save($groupOrder, $spreadUserId, $isFirstOrder);
|
||||
if ($consumption['type'] == StoreConsumption::TYPE_OWNER_CONSUMPTION && $storeActivityOrder['status'] == StoreActivityOrder::STATUS_VALID && $storeActivityOrder['red_pack'] == 0) {
|
||||
$this->orderType = 1;
|
||||
$this->send($consumption, $scope['rate'], $userId, $groupOrder['group_order_id'], $orderValidAmount, StoreConsumptionUser::STATUS_UNUSED);
|
||||
$this->send($consumption, $scope['rate_two'], $userId, $groupOrder['group_order_id'], $orderValidAmount, StoreConsumptionUser::STATUS_UNUSED, StoreConsumptionUser::TYPE_TWO);
|
||||
$storeActivityOrderDao->repeal($groupOrder['group_order_id']);
|
||||
@ -135,7 +122,7 @@ class StoreConsumptionUserDao extends BaseDao
|
||||
public function guest(int $userId, $groupOrder, int $spreadUserId)
|
||||
{
|
||||
// 查询推荐人的消费金类型
|
||||
$spreadActivityUser = (new StoreActivityUserDao())->default($spreadUserId);
|
||||
$spreadActivityUser = (new StoreActivityUserDao())->getOne($spreadUserId);
|
||||
$endTime = $this->getEndTime($spreadActivityUser['create_time'] ?? '2024-01-01 00:00:00');
|
||||
$spreadConsumption = (new StoreConsumptionDao())->getOne($spreadActivityUser['value'] ?? 0);
|
||||
// 查询推荐人满足条件的有效订单
|
||||
@ -165,7 +152,6 @@ class StoreConsumptionUserDao extends BaseDao
|
||||
$spreadOrderIds = "{$spreadGroupOrder['group_order_id']}," . $spreadOrderIds;
|
||||
// 使用了红包,订单有效金额需要乘以80%
|
||||
$orderValidAmount = $spreadGroupOrder['red_pack'] > 0 ? bcmul($orderValidAmount, 0.8, 2) : $orderValidAmount;
|
||||
$this->orderType = 1;
|
||||
$this->send($spreadConsumption, $spreadScope['rate'], $spreadUserId, $spreadOrderIds, $orderValidAmount);
|
||||
$storeActivityOrderDao->batchRepeal(explode(',', $spreadOrderIds));
|
||||
}
|
||||
@ -238,17 +224,12 @@ class StoreConsumptionUserDao extends BaseDao
|
||||
*/
|
||||
public function send($consumption, float $rate, int $userId, string $groupOrderIds, float $amount, $status = -2, $type = 1)
|
||||
{
|
||||
$title = $type == StoreConsumptionUser::TYPE_TWO ? '补贴' : '春耕采购余额';
|
||||
$title = $type == StoreConsumptionUser::TYPE_TWO ? '现金抵扣红包' : '无门槛实物通用红包';
|
||||
$model = StoreConsumptionUser::where('uid', $userId)->where('type', StoreConsumptionUser::TYPE_TWO)->find();
|
||||
$couponPrice = bcmul($amount, $rate, 2);
|
||||
if (!empty($model) && $model['type'] == $type) {
|
||||
if (!$this->onlyBill) {
|
||||
$model->coupon_price = bcadd($model->coupon_price, $couponPrice, 2);
|
||||
$model->balance = bcadd($model->balance, $couponPrice, 2);
|
||||
if ($model->status != StoreConsumptionUser::STATUS_UNUSED) {
|
||||
$model->status = StoreConsumptionUser::STATUS_UNUSED;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$model = new StoreConsumptionUser();
|
||||
$model->coupon_id = $consumption['coupon_id'];
|
||||
@ -259,13 +240,10 @@ class StoreConsumptionUserDao extends BaseDao
|
||||
$model->balance = $model->coupon_price;
|
||||
$model->order_amount = $amount;
|
||||
$model->create_time = date('Y-m-d H:i:s');
|
||||
$model->start_time = $this->startTime ?: date('Y-m-d H:i:s', time() + 7 * 86400);
|
||||
$model->end_time = $this->endTime ?: '2026-01-15 23:59:59';
|
||||
$model->start_time = date('Y-m-d H:i:s', time() + 7 * 86400);
|
||||
$model->end_time = '2026-01-15 23:59:59';
|
||||
$model->type = $type;
|
||||
$model->status = $status;
|
||||
if ($this->onlyBill === true) {
|
||||
$model->status = StoreConsumptionUser::STATUS_REPEAL;
|
||||
}
|
||||
}
|
||||
if (!$model->save()) {
|
||||
throw new \Exception('发放失败');
|
||||
@ -273,22 +251,12 @@ class StoreConsumptionUserDao extends BaseDao
|
||||
// 写入红包日志
|
||||
/** @var $userBillRepository UserBillRepository */
|
||||
$userBillRepository = app()->make(UserBillRepository::class);
|
||||
$extra = ['order_amount' => $amount, 'coupon_user_id' => $model['coupon_user_id']];
|
||||
if ($this->orderType == 2) {
|
||||
$extra['order_id'] = $groupOrderIds;
|
||||
} else {
|
||||
$extra['group_order_id'] = $groupOrderIds;
|
||||
}
|
||||
if (!empty($this->billExtra)) {
|
||||
$extra = array_merge($extra, $this->billExtra);
|
||||
}
|
||||
$userBillRepository->incBill($userId, 'red_pack', "red_pack_{$type}", [
|
||||
'link_id' => $model['coupon_user_id'],
|
||||
'status' => $status == -1 ?: 1,
|
||||
'status' => 1,
|
||||
'title' => '获得' . $title,
|
||||
'number' => $couponPrice,
|
||||
'mark' => '获得' . $title . $couponPrice . ",订单金额:{$amount}",
|
||||
'extra' => json_encode($extra, JSON_UNESCAPED_UNICODE),
|
||||
'balance' => 0
|
||||
]);
|
||||
}
|
||||
@ -316,7 +284,7 @@ class StoreConsumptionUserDao extends BaseDao
|
||||
->where('paid', 1)
|
||||
->whereBetweenTime('pay_time', $startTime, $endTime)
|
||||
->count();
|
||||
return intval($count <= 0);
|
||||
return intval($count <= 1);
|
||||
}
|
||||
|
||||
public function getEndTime($datetime)
|
||||
@ -324,26 +292,6 @@ class StoreConsumptionUserDao extends BaseDao
|
||||
return strtotime('+1 year', strtotime($datetime));
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加红包余额
|
||||
* @param $id
|
||||
* @param $amount
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function increase($id, $amount)
|
||||
{
|
||||
$storeConsumptionUser = StoreConsumptionUser::where('coupon_user_id', $id)->find();
|
||||
if (empty($storeConsumptionUser)) {
|
||||
throw new \Exception('红包记录不存在');
|
||||
}
|
||||
$storeConsumptionUser->balance = bcadd($storeConsumptionUser->balance, $amount, 2);
|
||||
if (!$storeConsumptionUser->save()) {
|
||||
throw new \Exception('红包余额更新出错');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 扣减红包余额
|
||||
* @param $id
|
||||
@ -359,17 +307,13 @@ class StoreConsumptionUserDao extends BaseDao
|
||||
throw new \Exception('红包余额不足');
|
||||
}
|
||||
$balance = bcsub($storeConsumptionUser->balance, $amount, 2);
|
||||
$storeConsumptionUser->balance = $balance;
|
||||
if ($balance <= 0 && $storeConsumptionUser->type == StoreConsumptionUser::TYPE_ONE) {
|
||||
$storeConsumptionUser->status = StoreConsumptionUser::STATUS_USED;
|
||||
}
|
||||
$storeConsumptionUser->balance = max($balance, 0);
|
||||
if (!$storeConsumptionUser->save()) {
|
||||
throw new \Exception('红包余额更新出错');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 已废弃,用下面的 typeTwoByProduct 和 typeOneByProduct
|
||||
* 根据订单商品计算实际金额和红包金额
|
||||
* @return array
|
||||
*/
|
||||
@ -387,8 +331,8 @@ class StoreConsumptionUserDao extends BaseDao
|
||||
$rate = bcdiv($productPrice, $orderTotalPrice, 5);
|
||||
$realPrice = $this->isLast ? bcsub($orderPayPrice, $realPriceTotal, 2) : ceil(bcmul($orderPayPrice, $rate, 5));
|
||||
$consumptionAmount = $productPrice - $realPrice;
|
||||
}
|
||||
$realPriceTotal += $realPrice;
|
||||
}
|
||||
$realPrice = bcdiv($realPrice, 100, 2);
|
||||
$consumptionAmount = bcdiv($consumptionAmount, 100, 2);
|
||||
$realPriceTotal = bcdiv($realPriceTotal, 100, 2);
|
||||
@ -397,7 +341,6 @@ class StoreConsumptionUserDao extends BaseDao
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 已废弃,用下面的 typeTwoByProduct 和 typeOneByProduct
|
||||
* 根据订单计算实际金额和红包金额
|
||||
* @return array
|
||||
*/
|
||||
@ -448,7 +391,7 @@ class StoreConsumptionUserDao extends BaseDao
|
||||
// 写入红包日志
|
||||
/** @var $userBillRepository UserBillRepository */
|
||||
$userBillRepository = app()->make(UserBillRepository::class);
|
||||
$title = $model['type'] == StoreConsumptionUser::TYPE_TWO ? '现金抵扣补贴' : '无门槛实物通用补贴';
|
||||
$title = $model['type'] == StoreConsumptionUser::TYPE_TWO ? '现金抵扣红包' : '无门槛实物通用红包';
|
||||
$userBillRepository->incBill($refundOrder['uid'], 'red_pack', "red_pack_{$model['type']}", [
|
||||
'link_id' => $refundOrder['order_id'],
|
||||
'status' => 1,
|
||||
@ -457,11 +400,6 @@ class StoreConsumptionUserDao extends BaseDao
|
||||
'mark' => '订单退款,获得' . $title . $refundOrder['refund_consumption'] . ",退款订单ID:{$refundOrder['order_id']}",
|
||||
'balance' => 0
|
||||
]);
|
||||
$financeDao = new FinancialDao();
|
||||
$financeDao->user = $order->user;
|
||||
$financeDao->order = $order;
|
||||
$financeDao->platformIn($refundOrder['refund_consumption'], 'platform_consumption_refund');
|
||||
$financeDao->save();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -497,83 +435,4 @@ class StoreConsumptionUserDao extends BaseDao
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 红包类型为 现金抵扣红包
|
||||
* 根据商品毛利率计算红包金额
|
||||
* @return array
|
||||
*/
|
||||
public function typeTwoByProduct()
|
||||
{
|
||||
// 把所有金额转换成分,避免红包金额产生误差
|
||||
$totalPrice = $this->orderProductPrice * 100;
|
||||
$consumptionUsed = $this->consumptionUsed * 100;
|
||||
$consumptionTotal = $this->consumptionTotalAmount * 100;
|
||||
$consumptionBalance = $consumptionTotal - $consumptionUsed;
|
||||
if ($consumptionBalance <= 0) {
|
||||
return [$this->orderProductPrice, '0.00', $this->consumptionUsed];
|
||||
}
|
||||
$rate = $this->getRate($this->profitRate);
|
||||
$useAmount = bcmul($totalPrice, $rate, 2);
|
||||
if ($useAmount >= $consumptionBalance) {
|
||||
$useAmount = $consumptionBalance;
|
||||
}
|
||||
$payPrice = $totalPrice - $useAmount;
|
||||
$consumptionUsed += $useAmount;
|
||||
$payPrice = bcdiv($payPrice, 100, 2);
|
||||
$useAmount = bcdiv($useAmount, 100, 2);
|
||||
$consumptionUsed = bcdiv($consumptionUsed, 100, 2);
|
||||
/** $payPrice:实际支付的金额,$useAmount:当前商品使用的红包金额,$consumptionUsed:使用的红包金额总计 */
|
||||
return [$payPrice, $useAmount, $consumptionUsed];
|
||||
}
|
||||
|
||||
/**
|
||||
* 红包类型为 无门槛红包
|
||||
* 根据商品毛利率计算红包金额
|
||||
* @return array
|
||||
*/
|
||||
public function typeOneByProduct()
|
||||
{
|
||||
// 把所有金额转换成分,避免红包金额产生误差
|
||||
$totalPrice = $this->orderProductPrice * 100;
|
||||
$consumptionUsed = $this->consumptionUsed * 100;
|
||||
$consumptionTotal = $this->consumptionTotalAmount * 100;
|
||||
$groupOrderTotalPrice = $this->groupOrderTotalPrice * 100;
|
||||
$rate = bcdiv($totalPrice, $groupOrderTotalPrice, 5);
|
||||
if ($consumptionTotal >= $groupOrderTotalPrice) {
|
||||
$useAmount = $totalPrice;
|
||||
} else {
|
||||
$useAmount = $this->isLast ? $consumptionTotal - $consumptionUsed : round(bcmul($consumptionTotal, $rate, 1));
|
||||
}
|
||||
$payPrice = $totalPrice - $useAmount;
|
||||
$consumptionUsed += $useAmount;
|
||||
$payPrice = bcdiv($payPrice, 100, 2);
|
||||
$useAmount = bcdiv($useAmount, 100, 2);
|
||||
$consumptionUsed = bcdiv($consumptionUsed, 100, 2);
|
||||
/** $payPrice:实际支付的金额,$useAmount:当前商品使用的红包金额,$consumptionUsed:使用的红包金额总计 */
|
||||
return [$payPrice, $useAmount, $consumptionUsed];
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品毛利率计算红包抵扣比例
|
||||
* @param float $profitRate 毛利率
|
||||
* @return float|int
|
||||
*/
|
||||
public function getRate($profitRate)
|
||||
{
|
||||
$rateArray = [
|
||||
'0.25' => 0.4,
|
||||
'0.2' => 0.3,
|
||||
'0.15' => 0.2,
|
||||
'0.1' => 0.1,
|
||||
];
|
||||
$rate = 0;
|
||||
foreach ($rateArray as $k => $item) {
|
||||
if ($profitRate >= $k) {
|
||||
$rate = $item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $rate;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -75,19 +75,13 @@ class StoreOrderDao extends BaseDao
|
||||
$query->where('is_del', 0);
|
||||
});
|
||||
if (isset($where['source']) && ($where['source'] == 103||$where['source'] == 105)) {
|
||||
$wheres['activity_type'] = [0, 2, 98];
|
||||
$wheres['source'] = [0,2,103,105,999];
|
||||
$query->where($wheres);
|
||||
unset($where['source']);
|
||||
} elseif (isset($where['source']) && ($where['source'] == 11 || $where['source'] == 12)) {
|
||||
$wheres['activity_type'] = 98;
|
||||
$wheres['source'] = [$where['source'], 999];
|
||||
$wheres['activity_type'] = [0,98];
|
||||
$wheres['source'] = [0,2,103,105];
|
||||
$query->where($wheres);
|
||||
unset($where['source']);
|
||||
} else {
|
||||
if(isset($where['product_type']) && $where['product_type'] !== ''){
|
||||
$where['product_type'] = [$where['product_type'], 2];
|
||||
$query->whereIn('activity_type', $where['product_type']);
|
||||
$query->where('activity_type', $where['product_type']);
|
||||
}
|
||||
}
|
||||
$query->when(($sysDel !== null), function ($query) use ($sysDel) {
|
||||
|
@ -15,25 +15,18 @@ namespace app\common\dao\store\order;
|
||||
|
||||
|
||||
use app\common\dao\BaseDao;
|
||||
use app\common\dao\system\financial\FinancialDao;
|
||||
use app\common\model\store\order\StoreGroupOrderOther;
|
||||
use app\common\model\store\order\StoreOrderOther;
|
||||
use app\common\model\store\order\StoreOrderProductOther;
|
||||
use app\common\model\store\order\StoreOrderStatusOther;
|
||||
use app\common\model\store\order\StoreRefundOrder;
|
||||
use app\common\model\store\order\StoreRefundOrderOther;
|
||||
use app\common\model\store\order\StoreRefundProductOther;
|
||||
use app\common\model\system\merchant\FinancialRecord;
|
||||
use app\common\repositories\store\order\StoreOrderStatusRepository;
|
||||
use app\common\repositories\store\product\ProductAssistSetRepository;
|
||||
use app\common\repositories\store\product\ProductGroupBuyingRepository;
|
||||
|
||||
use app\common\repositories\system\merchant\MerchantRepository;
|
||||
use think\db\BaseQuery;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Db;
|
||||
use think\Model;
|
||||
|
||||
@ -771,99 +764,4 @@ class StoreOrderOtherDao extends BaseDao
|
||||
});
|
||||
})->where('StoreOrderOther.uid', $uid)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* 供应链订单退款
|
||||
* @param $refundOrder
|
||||
* @return void
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function refund($refundOrder)
|
||||
{
|
||||
$refundProducts = [];
|
||||
foreach ($refundOrder->refundProduct->toArray() as $item) {
|
||||
$refundProducts[$item['product']['product_source_id']] = ['num' => $item['refund_num']];
|
||||
}
|
||||
$order = StoreOrderOther::where('order_sn', $refundOrder->order['order_sn'])->find();
|
||||
if (empty($order)) {
|
||||
return;
|
||||
}
|
||||
$refundOrderArray = $refundOrder->toArray();
|
||||
unset($refundOrderArray['refund_order_id'], $refundOrderArray['refundProduct'], $refundOrderArray['order']);
|
||||
Db::startTrans();
|
||||
try {
|
||||
$products = [];
|
||||
$refundTotal = 0.00;
|
||||
$orderProducts = StoreOrderProductOther::where('order_id', $order['order_id'])->select();
|
||||
foreach ($orderProducts as $orderProduct) {
|
||||
$refundProduct = $refundProducts[$orderProduct['product_id']] ?? [];
|
||||
if (empty($refundProduct)) {
|
||||
continue;
|
||||
}
|
||||
$price = bcdiv($orderProduct['total_price'], $orderProduct['product_num'], 2);
|
||||
$refundPrice = bcmul($price, $refundProduct['num'], 2);
|
||||
$refundTotal = bcadd($refundTotal, $refundPrice, 2);
|
||||
$products[] = [
|
||||
'order_product_id' => $orderProduct['order_product_id'],
|
||||
'refund_price' => $refundPrice,
|
||||
'refund_consumption' => 0,
|
||||
'platform_refund_price' => 0,
|
||||
'refund_postage' => 0,
|
||||
'refund_integral' => 0,
|
||||
'refund_num' => $refundProduct['num'],
|
||||
];
|
||||
$orderProduct->refund_num -= $refundProduct['num'];
|
||||
$orderProduct->is_refund = 1;
|
||||
$orderProduct->save();
|
||||
}
|
||||
$model = new StoreRefundOrderOther();
|
||||
$model->setAttrs($refundOrderArray);
|
||||
$model->order_id = $order['order_id'];
|
||||
$model->uid = $order['uid'];
|
||||
$model->mer_id = $order['mer_id'];
|
||||
$model->refund_price = $refundTotal;
|
||||
$model->save();
|
||||
|
||||
foreach ($products as &$product) {
|
||||
$product['refund_order_id'] = $model->refund_order_id;
|
||||
}
|
||||
if (count($products) > 0) {
|
||||
StoreRefundProductOther::getDB()->insertAll($products);
|
||||
}
|
||||
|
||||
$financeDao = new FinancialDao();
|
||||
$financeDao->user = $order->user;
|
||||
$financeDao->order = $order;
|
||||
$financeDao->order->order_id = $model->refund_order_id;
|
||||
$financeDao->platformIn($refundTotal, 'supply_chain_refund', $model->mer_id);
|
||||
|
||||
$marginRecord = FinancialRecord::where('order_id', $refundOrder['order_id'])
|
||||
->where('mer_id', $model->mer_id)
|
||||
->where('financial_type', 'auto_margin')
|
||||
->value('number');
|
||||
$marginRefunded = FinancialRecord::where('order_id', $refundOrder['order_id'])
|
||||
->where('mer_id', $model->mer_id)
|
||||
->where('financial_type', 'auto_margin_refund')
|
||||
->sum('number');
|
||||
if ($marginRecord > $marginRefunded) {
|
||||
/** @var MerchantRepository $merchantRepo */
|
||||
$merchantRepo = app()->make(MerchantRepository::class);
|
||||
$merchantRepo->forceMargin = false;
|
||||
$merchantRepo->merId = $model->mer_id;
|
||||
[$margin, $financeDao] = $merchantRepo->refundDeposit($refundTotal, $financeDao);
|
||||
$merchantRepo->addLockMoney($model->mer_id, 'order', $refundOrder['order_id'], $margin);
|
||||
}
|
||||
|
||||
$financeDao->save();
|
||||
|
||||
app()->make(MerchantRepository::class)->subLockMoney($model->mer_id, 'order', $refundOrder['order_id'], $refundTotal);
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
throw new ValidateException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class StoreRefundProductDao extends BaseDao
|
||||
$lst = $this->getModel()::getDB()->alias('A')->leftJoin('StoreRefundOrder B', 'A.refund_order_id = B.refund_order_id')
|
||||
->where('B.status', '>', -1)
|
||||
->whereIn('A.order_product_id', $ids)->group('A.order_product_id')
|
||||
->field('A.order_product_id, SUM(A.refund_price) as refund_price, SUM(A.platform_refund_price) as platform_refund_price, SUM(A.refund_postage) as refund_postage, SUM(A.refund_integral) as refund_integral, SUM(A.refund_consumption) as refund_consumption')
|
||||
->field('A.order_product_id, SUM(A.refund_price) as refund_price, SUM(A.platform_refund_price) as platform_refund_price, SUM(A.refund_postage) as refund_postage, SUM(A.refund_integral) as refund_integral')
|
||||
->select()->toArray();
|
||||
$data = [];
|
||||
foreach ($lst as $item) {
|
||||
|
@ -151,6 +151,9 @@ class ProductDao extends BaseDao
|
||||
});
|
||||
}
|
||||
})
|
||||
->when(isset($where['keyword']) && $where['keyword'] !== '', function ($query) use ($where) {
|
||||
$query->whereLike('Product.store_name', "%{$where['keyword']}%");
|
||||
})
|
||||
->when(isset($where['mer_labels']) && $where['mer_labels'] !== '', function ($query) use ($where) {
|
||||
$query->whereLike('U.mer_labels', "%,{$where['mer_labels']},%");
|
||||
})
|
||||
@ -171,11 +174,7 @@ class ProductDao extends BaseDao
|
||||
}
|
||||
$query->order($where['order'] . ',rank DESC ,create_time DESC ');
|
||||
} else if($where['order'] !== ''){
|
||||
if($where['order'] == 'check'){
|
||||
$query->order('Product.update_time DESC');
|
||||
}else{
|
||||
$query->order('U.'.$where['order'].' DESC,U.create_time DESC');
|
||||
}
|
||||
} else {
|
||||
$query->order('U.create_time DESC');
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
namespace app\common\dao\store\product;
|
||||
|
||||
use app\common\dao\BaseDao;
|
||||
use app\common\model\store\product\ProductAttrValue;
|
||||
use app\common\model\store\product\ProductCate;
|
||||
use app\common\model\store\product\Spu;
|
||||
use app\common\model\store\StoreCategory;
|
||||
@ -55,11 +54,6 @@ class SpuDao extends BaseDao
|
||||
if(isset($where['order']) && $where['order'] === 'none'){
|
||||
$order = '';
|
||||
}
|
||||
|
||||
if(isset($where['order_remark']) && $where['order_remark'] === 'none'){
|
||||
$order = '';
|
||||
}
|
||||
|
||||
$query = Spu::getDB()->alias('S')->join('StoreProduct P','S.product_id = P.product_id', 'left');
|
||||
$query->when(isset($where['is_del']) && $where['is_del'] !== '',function($query)use($where){
|
||||
$query->where('P.is_del',$where['is_del']);
|
||||
@ -76,7 +70,7 @@ class SpuDao extends BaseDao
|
||||
->when(isset($where['mer_array_id']),function($query)use($where){
|
||||
$query->whereIn('P.mer_id',$where['mer_array_id']);
|
||||
})
|
||||
->when(isset($where['mer_ids']) && count($where['mer_ids'])>0,function($query)use($where){
|
||||
->when(isset($where['mer_ids']) && $where['mer_ids'] !== '',function($query)use($where){
|
||||
$query->whereIn('P.mer_id',$where['mer_ids']);
|
||||
})
|
||||
->when(isset($where['keyword']) && $where['keyword'] !== '',function($query)use($where){
|
||||
@ -95,9 +89,9 @@ class SpuDao extends BaseDao
|
||||
->when(isset($where['is_trader']) && $where['is_trader'] !== '',function($query)use($where){
|
||||
$merId = app()->make(MerchantRepository::class)->search([
|
||||
'is_trader' => $where['is_trader'],
|
||||
'status' => 1,//状态正常
|
||||
'mer_state' => 1,//商户开启
|
||||
'is_del' => 1,//
|
||||
'status' => 1,
|
||||
'mer_state' => 1,
|
||||
'is_del' => 1,
|
||||
])->column('mer_id');
|
||||
|
||||
$query->whereIn('P.mer_id',$merId);
|
||||
@ -193,18 +187,6 @@ class SpuDao extends BaseDao
|
||||
else if ($where['hot_type'] == 'best') $query->where('P.is_best', 1);
|
||||
else if ($where['hot_type'] == 'good') $query->where('P.is_benefit', 1);
|
||||
})
|
||||
->when(isset($where['deduction_rate']) && $where['deduction_rate'] !== '', function($query) use ($where) {
|
||||
$maxRate = $where['deduction_rate'] == 25 ? 100 : $where['deduction_rate'] + 5;
|
||||
$productIds = ProductAttrValue::when(isset($where['mer_id']) && $where['mer_id'] !== '', function($query) use ($where) {
|
||||
$query->where('mer_id', $where['mer_id']);
|
||||
})->where('profit_rate', '>=', $where['deduction_rate'])
|
||||
->where('profit_rate', '<', $maxRate)
|
||||
->column('product_id');
|
||||
if (empty($productIds)) {
|
||||
$productIds = [0];
|
||||
}
|
||||
$query->whereIn('S.product_id', $productIds);
|
||||
})
|
||||
->when(isset($where['svip']) && $where['svip'] !== '',function($query)use($where){
|
||||
$query->where('svip_price_type','>',0)->where('mer_svip_status',1);
|
||||
})->when($order, function ($query) use ($where, $order) {
|
||||
|
@ -93,7 +93,7 @@ class FinancialDao extends BaseDao
|
||||
* @param $financialType
|
||||
* @param $merId
|
||||
*/
|
||||
public function platformOut($number, $financialType, $merId = 0)
|
||||
public function platformOut($number, $financialType, $merId = '')
|
||||
{
|
||||
$this->setData($number, $financialType, 0, 2, $merId);
|
||||
}
|
||||
@ -104,7 +104,7 @@ class FinancialDao extends BaseDao
|
||||
* @param $financialType
|
||||
* @param $merId
|
||||
*/
|
||||
public function platformIn($number, $financialType, $merId = 0)
|
||||
public function platformIn($number, $financialType, $merId = '')
|
||||
{
|
||||
$this->setData($number, $financialType, 1, 2, $merId);
|
||||
}
|
||||
@ -131,28 +131,6 @@ class FinancialDao extends BaseDao
|
||||
$this->setData($number, $financialType, 1, 1, $merId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商户入账财务流水
|
||||
* @param $number
|
||||
* @param $financialType
|
||||
* @param $merId
|
||||
*/
|
||||
public function merchantOut($number, $financialType, $merId = '')
|
||||
{
|
||||
$this->setData($number, $financialType, 0, 0, $merId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商户入账财务流水
|
||||
* @param $number
|
||||
* @param $financialType
|
||||
* @param $merId
|
||||
*/
|
||||
public function merchantIn($number, $financialType, $merId = '')
|
||||
{
|
||||
$this->setData($number, $financialType, 1, 0, $merId);
|
||||
}
|
||||
|
||||
public function setData($number, $financialType, $pm, $type = 2, $merId = '')
|
||||
{
|
||||
if (empty($this->financeSn)) {
|
||||
@ -160,15 +138,15 @@ class FinancialDao extends BaseDao
|
||||
$this->financeSn = $financialRecordRepository->getSn();
|
||||
}
|
||||
$this->list[] = [
|
||||
'order_id' => $this->order['order_id'],
|
||||
'order_sn' => $this->order['order_sn'],
|
||||
'order_id' => $this->order->order_id,
|
||||
'order_sn' => $this->order->order_sn,
|
||||
'user_info' => $this->user['nickname'],
|
||||
'user_id' => $this->user['uid'],
|
||||
'financial_type' => $financialType,
|
||||
'financial_pm' => $pm,
|
||||
'type' => $type,
|
||||
'number' => $number,
|
||||
'mer_id' => $merId !== '' ? $merId : $this->order->mer_id,
|
||||
'mer_id' => !empty($merId) ? $merId : $this->order->mer_id,
|
||||
'financial_record_sn' => $this->financeSn . ($this->index++)
|
||||
];
|
||||
}
|
||||
|
@ -82,12 +82,9 @@ class FinancialRecordDao extends BaseDao
|
||||
->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) {
|
||||
getModelTime($query, $where['date'], 'create_time');
|
||||
})
|
||||
->when(isset($where['order_id']) && $where['order_id'] !== '', function ($query) use ($where) {
|
||||
$query->where('order_id', $where['order_id']);
|
||||
})
|
||||
->when(isset($where['is_mer']) && $where['is_mer'] !== '', function ($query) use ($where) {
|
||||
if($where['is_mer']){
|
||||
$query->where('mer_id',$where['is_mer'])->where('type','in',[0,1, 2]);
|
||||
$query->where('mer_id',$where['is_mer'])->where('type','in',[0,1]);
|
||||
}else{
|
||||
$query->where('type','in',[1,2]);
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ class UserBillDao extends BaseDao
|
||||
$lockMoney = 0;
|
||||
if (count($lst)) {
|
||||
$lockMoney = -1 * UserBill::getDB()->whereIn('link_id', array_column($lst, 'link_id'))
|
||||
->where('category', 'mer_refund_money')->where('mer_id', $merId)->sum('number');
|
||||
->where('category', 'mer_refund_money')->sum('number');
|
||||
}
|
||||
foreach ($lst as $bill) {
|
||||
$lockMoney = bcadd($lockMoney, $bill['number'], 2);
|
||||
@ -191,13 +191,8 @@ class UserBillDao extends BaseDao
|
||||
{
|
||||
return UserBill::getDB()
|
||||
->when(isset($where['now_money']) && in_array($where['now_money'], [0, 1, 2]), function ($query) use ($where) {
|
||||
if ($where['now_money'] == 0) //->whereIn('category', ['now_money','brokerage'])
|
||||
$query->whereIn('type', ['pay_product', 'recharge', 'sys_inc_money', 'sys_dec_money', 'brokerage', 'presell', 'refund', 'zhibo_reward_inc', 'zhibo_reward_dec','order_one'])
|
||||
->where(function ($query) {
|
||||
$query->where('category', 'now_money')
|
||||
->whereOr('category', 'brokerage');
|
||||
})
|
||||
;
|
||||
if ($where['now_money'] == 0)
|
||||
$query->where('category', 'now_money')->whereIn('type', ['pay_product', 'recharge', 'sys_inc_money', 'sys_dec_money', 'brokerage', 'presell', 'refund', 'zhibo_reward_inc', 'zhibo_reward_dec']);
|
||||
else if ($where['now_money'] == 1)
|
||||
$query->where('category', 'now_money')->whereIn('type', ['pay_product', 'sys_dec_money', 'presell', 'zhibo_reward_dec']);
|
||||
else if ($where['now_money'] == 2)
|
||||
|
@ -62,8 +62,6 @@ class UserTokenMiddleware extends BaseMiddleware
|
||||
throw new AuthException('用户不存在');
|
||||
if (!$user['status'])
|
||||
throw new AuthException('用户已被禁用');
|
||||
if ($user['status'] == -1)
|
||||
throw new AuthException('当前账号已合并,请重新登录');
|
||||
if ($user['cancel_time'])
|
||||
throw new AuthException('用户不存在');
|
||||
|
||||
|
@ -15,8 +15,6 @@ class StoreConsumption extends BaseModel
|
||||
const TYPE_OWNER_CONSUMPTION = 13; //个人消费金
|
||||
const TYPE_PULL_CONSUMPTION = 14; //拉新消费金
|
||||
const TYPE_FIRST_ORDER_COMMISSION = 15; //首单佣金
|
||||
const TYPE_RECHARGE = 16; //充值赠送
|
||||
const TYPE_SALE_SUBSIDY = 17; //销售补贴
|
||||
|
||||
public static function tablePk(): string
|
||||
{
|
||||
|
@ -12,12 +12,12 @@ class StoreConsumptionUser extends BaseModel
|
||||
const STATUS_UNUSED = 0; //未使用
|
||||
const STATUS_USED = 1; //已使用
|
||||
const STATUS_OVERDUE = 2; //过期的
|
||||
const TYPE_ONE = 1; //实物通用补贴
|
||||
const TYPE_TWO = 2; //现金抵扣补贴
|
||||
const TYPE_ONE = 1; //实物通用红包
|
||||
const TYPE_TWO = 2; //现金抵扣红包
|
||||
|
||||
const TYPE_MAP = [
|
||||
self::TYPE_ONE => '无门槛实物通用补贴',
|
||||
self::TYPE_TWO => '现金抵扣补贴',
|
||||
self::TYPE_ONE => '无门槛实物通用红包',
|
||||
self::TYPE_TWO => '现金抵扣红包',
|
||||
];
|
||||
|
||||
public static function tablePk(): string
|
||||
|
@ -182,7 +182,7 @@ class StoreCart extends BaseModel
|
||||
switch ($this->product_type)
|
||||
{
|
||||
case 0: //普通商品
|
||||
if (($this->product->product_type !== 0 || $this->product->is_show !== 1 || $this->productAttr->stock < $this->cart_num || $this->product->is_used !== 1) && !$this->product->isPickupCard()) {
|
||||
if ($this->product->product_type !== 0 || $this->product->is_show !== 1 || $this->productAttr->stock < $this->cart_num || $this->product->is_used !== 1) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@ -239,7 +239,7 @@ class StoreCart extends BaseModel
|
||||
if($sku->stock < $this->cart_num || $sku->sku->stock < $this->cart_num) return false;
|
||||
break;
|
||||
case 98: //供应链商品
|
||||
if (($this->product->product_type !== 98 || $this->product->is_show !== 1 || $this->productAttr->stock < $this->cart_num || $this->product->is_used !== 1) && !$this->product->isPickupCard()) {
|
||||
if ($this->product->product_type !== 98 || $this->product->is_show !== 1 || $this->productAttr->stock < $this->cart_num || $this->product->is_used !== 1) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
@ -26,7 +26,6 @@ class StoreGroupOrder extends BaseModel
|
||||
const PAY_TYPE_ROUTINE = 2; //小程序支付
|
||||
const PAY_TYPE_H5 = 3; //H5支付
|
||||
const PAY_TYPE_CREDIT_BUY = 8; //信用购 先货后款
|
||||
const PAY_TYPE_MER_BALANCE = 9; //商户余额支付
|
||||
const ON_LINE_PRODUCT = 9; //线上铺货
|
||||
const ENTITY_PRODUCT = 10; //实体铺货
|
||||
const ON_CREDIT_PRODUCT = 11; //赊账进货
|
||||
|
@ -52,7 +52,7 @@ class StoreOrderOther extends BaseModel
|
||||
|
||||
public function refundOrder()
|
||||
{
|
||||
return $this->hasMany(StoreRefundOrderOther::class,'order_id','order_id');
|
||||
return $this->hasMany(StoreRefundOrder::class,'order_id','order_id');
|
||||
}
|
||||
|
||||
public function orderStatus()
|
||||
@ -192,12 +192,4 @@ class StoreOrderOther extends BaseModel
|
||||
return $this->pay_type == StoreGroupOrder::PAY_TYPE_CREDIT_BUY && $this->status == self::STATUS_WAIT_PAY;
|
||||
}
|
||||
|
||||
|
||||
public function chageVoucher(int $id,string $voucher)
|
||||
{
|
||||
return $this->getModel()::getDB()->where('order_id',$id)->update(['payment_voucher' => $voucher]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\store\order;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\model\user\User;
|
||||
|
||||
class StoreRefundOrderOther extends BaseModel
|
||||
{
|
||||
|
||||
public static function tablePk(): ?string
|
||||
{
|
||||
return 'refund_order_id';
|
||||
}
|
||||
|
||||
public static function tableName(): string
|
||||
{
|
||||
return 'store_refund_order_other';
|
||||
}
|
||||
|
||||
public function refundProduct()
|
||||
{
|
||||
return $this->hasMany(StoreRefundProductOther::class, 'refund_order_id', 'refund_order_id');
|
||||
}
|
||||
|
||||
public function merchant()
|
||||
{
|
||||
return $this->hasOne(Merchant::class, 'mer_id', 'mer_id');
|
||||
}
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->hasOne(User::class, 'uid', 'uid');
|
||||
}
|
||||
|
||||
public function orders()
|
||||
{
|
||||
return $this->hasOne(StoreOrderOther::class, 'order_id', 'order_id');
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\store\order;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
|
||||
class StoreRefundProductOther extends BaseModel
|
||||
{
|
||||
|
||||
public static function tablePk(): ?string
|
||||
{
|
||||
return 'refund_product_id';
|
||||
}
|
||||
|
||||
public static function tableName(): string
|
||||
{
|
||||
return 'store_refund_product_other';
|
||||
}
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->hasOne(StoreOrderProductOther::class,'order_product_id','order_product_id');
|
||||
}
|
||||
|
||||
public function refundOrder()
|
||||
{
|
||||
return $this->hasOne(StoreRefundOrderOther::class,'refund_order_id','refund_order_id');
|
||||
}
|
||||
|
||||
}
|
@ -589,28 +589,4 @@ class Product extends BaseModel
|
||||
return $this->mer_status == 1 && $this->status == 1 && $this->is_del == 0 && $this->is_show == self::IS_SHOW && $this->is_used == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为平台卡商品
|
||||
* @return bool
|
||||
*/
|
||||
public function isPlatformCard()
|
||||
{
|
||||
if (!empty($this->merCateId) && in_array(env('PLATFORM_CARD_CATE_ID'), array_column($this->merCateId->toArray(), 'mer_cate_id'))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为实物提货券
|
||||
* @return bool
|
||||
*/
|
||||
public function isPickupCard()
|
||||
{
|
||||
if (!empty($this->cate_id) && $this->cate_id == env('PICKUP_CARD_CATE_ID')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -50,26 +50,4 @@ class FinancialRecord extends BaseModel
|
||||
{
|
||||
return $this->hasOne(StoreRefundOrder::class,'refund_order_sn','order_sn');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取备注
|
||||
* @return string
|
||||
*/
|
||||
public function getMark()
|
||||
{
|
||||
switch ($this->financial_type) {
|
||||
case 'commission_to_platform':
|
||||
return '平台手续费:' . $this->number;
|
||||
case 'platform_consumption':
|
||||
return '使用平台优惠:' . $this->number;
|
||||
case 'auto_margin':
|
||||
return '保证金:' . $this->number;
|
||||
case 'commission_to_promoter':
|
||||
$nickname = User::where('uid', $this->user_id)->value('nickname');
|
||||
return "“{$nickname}”获得推广佣金:" . $this->number;
|
||||
default:
|
||||
return '商户入账:' . $this->number;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ use app\common\model\system\config\SystemConfigValue;
|
||||
use app\common\model\system\financial\Financial;
|
||||
use app\common\model\system\GeoStreet;
|
||||
use app\common\model\system\serve\ServeOrder;
|
||||
use app\common\model\user\User;
|
||||
use app\common\repositories\store\StoreActivityRepository;
|
||||
use think\facade\Db;
|
||||
|
||||
@ -317,13 +316,4 @@ class Merchant extends BaseModel
|
||||
return $this->hasOne(GeoStreet::class, 'street_code', 'street_id');
|
||||
}
|
||||
|
||||
public function promoter()
|
||||
{
|
||||
$spreadId = User::where('uid', $this->uid)->value('spread_uid');
|
||||
if ($spreadId > 0) {
|
||||
return User::where('uid', $spreadId)->field('uid,nickname')->find();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,6 @@
|
||||
namespace app\common\repositories\store\order;
|
||||
|
||||
|
||||
use app\common\dao\store\consumption\StoreConsumptionUserDao;
|
||||
use app\common\dao\store\order\StoreGroupOrderDao;
|
||||
use app\common\model\store\order\StoreGroupOrder;
|
||||
use app\common\model\store\order\StoreOrder;
|
||||
@ -67,7 +66,7 @@ class StoreGroupOrderRepository extends BaseRepository
|
||||
{
|
||||
$query = StoreGroupOrder::getDB()->alias('StoreGroupOrder');
|
||||
if(isset($where['source']) && $where['source'] == 103){
|
||||
$wheres['activity_type']=[0, 2, 98];
|
||||
$wheres['activity_type']=[0,98];
|
||||
$wheres['source']=[0,2,103,105];
|
||||
}else{
|
||||
$wheres['activity_type']=0;
|
||||
@ -227,10 +226,6 @@ class StoreGroupOrderRepository extends BaseRepository
|
||||
}
|
||||
$groupOrder->save();
|
||||
$storeOrderStatusRepository->batchCreateLog($orderStatus);
|
||||
if ($groupOrder->consumption_id > 0 && $groupOrder->consumption_money > 0) {
|
||||
$storeConsumptionUserDao = new StoreConsumptionUserDao();
|
||||
$storeConsumptionUserDao->increase($groupOrder['consumption_id'], $groupOrder['consumption_money']);
|
||||
}
|
||||
});
|
||||
Queue::push(CancelGroupOrderJob::class, $id);
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ use app\common\dao\store\order\StoreCartDao;
|
||||
use app\common\dao\store\StoreActivityDao;
|
||||
use app\common\model\store\order\StoreGroupOrder;
|
||||
use app\common\model\store\order\StoreOrder;
|
||||
use app\common\model\store\product\ProductCate;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\repositories\community\CommunityRepository;
|
||||
use app\common\repositories\store\coupon\StoreCouponRepository;
|
||||
@ -31,7 +30,6 @@ use crmeb\jobs\SendSmsJob;
|
||||
use crmeb\services\SwooleTaskService;
|
||||
use crmeb\utils\Curl;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Db;
|
||||
use think\facade\Queue;
|
||||
|
||||
@ -83,35 +81,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
//检查商品类型, 活动商品只能单独购买
|
||||
$allowDelivery = true;
|
||||
$activityProductCount = 0;
|
||||
//判断是否是平台购物卡,购物卡不允许使用任何优惠券
|
||||
$isPlatformCard = $merchantCartList[0]['list'][0]['product']->isPlatformCard();
|
||||
$isPickupCard = $merchantCartList[0]['list'][0]['product']->isPickupCard();
|
||||
if ($isPickupCard) {
|
||||
$totalAmount = Cache::get('cart_id_' . $cartId[0]);
|
||||
if (empty($totalAmount)) {
|
||||
throw new ValidateException('数据已过期,请重新扫码下单');
|
||||
}
|
||||
}
|
||||
if ($isPlatformCard) {
|
||||
$merchantTypeId = Merchant::where('uid', $uid)->value('type_id');
|
||||
if (empty($merchantTypeId) || $merchantTypeId != 21) {
|
||||
throw new ValidateException('大礼包仅限种养殖户购买');
|
||||
}
|
||||
//平台购物卡仅能购买一次
|
||||
$productIds = ProductCate::where('mer_cate_id', env('PLATFORM_CARD_CATE_ID'))->column('product_id');
|
||||
$orderRecord = StoreOrder::alias('t1')
|
||||
->leftJoin('store_order_product t2', 't1.order_id = t2.order_id')
|
||||
->whereIn('product_id', $productIds)
|
||||
->where('t1.uid', $uid)
|
||||
->where('paid', 1)
|
||||
->where('is_refund', 0)
|
||||
->count();
|
||||
if ($orderRecord > 0) {
|
||||
throw new ValidateException('大礼包仅能购买一次');
|
||||
}
|
||||
}
|
||||
foreach ($merchantCartList as $merchantCart) {
|
||||
if (($merchantCart['type_id'] != Merchant::TypeSupplyChain) && $address && $merchantCart['list'][0]['product_type'] != 2 && $merchantCart['list'][0]['product']['type'] != 1) {
|
||||
if (($merchantCart['type_id'] != Merchant::TypeSupplyChain) && $address) {
|
||||
if ($merchantCart['street_id'] != $address['street_code'] && $createOrder && !in_array($merchantCart['mer_id'], $takes)) {
|
||||
throw new ValidateException('不支持跨区域购买,请在【我的】-【地址管理】更改后重新购买');
|
||||
}
|
||||
@ -164,7 +135,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
$order_extend = json_decode($cart['product']['extend'], true);
|
||||
}
|
||||
if ($address) {
|
||||
if (($cart['source'] == 0 || $cart['source'] == 103) && $cart['product']['type'] != 1) {
|
||||
if ($cart['source'] == 0 || $cart['source'] == 103) {
|
||||
$userAddressCode = ($address['province_code'] ?? '') . ',' . ($address['city_code'] ?? '') . ',' . ($address['district_code'] ?? '') . ',' . ($address['street_code'] ?? '') . ',' . ($address['village_code'] ?? '') . ',' . ($address['brigade_id'] ?? 0);
|
||||
$getUrl = env('LOGISTICS_HOST_URL') . '/api/hasCourier?user_address_code=' . $userAddressCode;
|
||||
$curl = new Curl();
|
||||
@ -190,12 +161,13 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
$presellType = 0;
|
||||
$consumption_coupon_id = 0;
|
||||
$fn = [];
|
||||
if (in_array($source, [0, 2, 103])) {
|
||||
$enabledPlatformCoupon = true;
|
||||
$order_total_postage = 0;
|
||||
$platformCoupon = [];
|
||||
if ($isPlatformCard) {
|
||||
} else {
|
||||
$enabledPlatformCoupon = false;
|
||||
}
|
||||
$order_total_postage = 0;
|
||||
$platformCoupon = [];
|
||||
|
||||
|
||||
//套餐订单
|
||||
@ -275,7 +247,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
$enabledCoupon = !($order_type && $order_type != 2);
|
||||
|
||||
//只有预售和普通商品可以用优惠券
|
||||
if (!$enabledCoupon || $isPlatformCard || $isPickupCard) {
|
||||
if (!$enabledCoupon) {
|
||||
$merchantCart['coupon'] = [];
|
||||
}
|
||||
$svip_coupon_merge = merchantConfig($merchantCart['mer_id'], 'svip_coupon_merge');
|
||||
@ -301,18 +273,12 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
$cart['productAttr']['stock'] = $cart['cart_num'];
|
||||
}
|
||||
$price = bcmul($cart['cart_num'], $realPrice, 2);
|
||||
if ($isPickupCard && !empty($totalAmount)) {
|
||||
$price = $totalAmount;
|
||||
}
|
||||
$cart['total_price'] = $price;
|
||||
$cart['postage_price'] = 0;
|
||||
$cart['svip_discount'] = 0;
|
||||
$total_price = bcadd($total_price, $price, 2);
|
||||
$total_num += $cart['cart_num'];
|
||||
$_price = bcmul($cart['cart_num'], $this->cartByCouponPrice($cart), 2);
|
||||
if ($isPickupCard && !empty($totalAmount)) {
|
||||
$_price = $totalAmount;
|
||||
}
|
||||
$cart['svip_coupon_merge'] = 1;
|
||||
if ($cart['productAttr']['show_svip_price'] && !$cart['product_type']) {
|
||||
$svip_discount = max(bcmul($cart['cart_num'], bcsub($cart['productAttr']['org_price'] ?? 0, $cart['productAttr']['price'], 2), 2), 0);
|
||||
@ -481,22 +447,16 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
}
|
||||
|
||||
//计算单个商品实际支付金额
|
||||
$orderProcurePrice = 0;
|
||||
foreach ($merchantCart['list'] as $_k => &$cart) {
|
||||
$cartTotalPrice = bcmul($this->cartByPrice($cart), $cart['cart_num'], 2);
|
||||
if ($isPickupCard && !empty($totalAmount)) {
|
||||
$cartTotalPrice = $totalAmount;
|
||||
}
|
||||
$_cartTotalPrice = $cartTotalPrice;
|
||||
|
||||
//单个商品实际支付金额
|
||||
$cart['coupon_price'] = bcsub($_cartTotalPrice, $cartTotalPrice, 2);
|
||||
$cart['true_price'] = $cartTotalPrice;
|
||||
}
|
||||
$procure = $this->cartByPrice($cart, 1);
|
||||
$procure_price = bcmul($cart['cart_num'], $procure, 2);
|
||||
$cart['profit_rate'] = bcdiv(($cartTotalPrice - $procure_price), $cartTotalPrice, 2);
|
||||
$orderProcurePrice = bcadd($orderProcurePrice, $procure_price, 2);
|
||||
}
|
||||
unset($cart, $_k);
|
||||
$total_true_price = bcadd($_pay_price, $total_true_price, 2);
|
||||
if (count($merchantCartList) > 1 || count($merchantCart['list']) > 1) {
|
||||
@ -522,7 +482,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
'delivery_status' => $deliveryStatus,
|
||||
'svip_discount' => $total_svip_discount,
|
||||
'use_svip' => $use_svip,
|
||||
'procure_price' => $orderProcurePrice
|
||||
'procure_price' => $procure_price
|
||||
];
|
||||
$order_total_postage = bcadd($order_total_postage, $postage_price, 2);
|
||||
$order_svip_discount = bcadd($total_svip_discount, $order_svip_discount, 2);
|
||||
@ -558,26 +518,15 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
// if ($total_true_price > 0) {
|
||||
$StoreCouponUser = app()->make(StoreCouponUserRepository::class);
|
||||
$platformCoupon = $StoreCouponUser->validUserPlatformCoupon($uid);
|
||||
$platformConsumption = [];
|
||||
//消费金
|
||||
if ($source == 103) {
|
||||
$ConsumptionWhere = [
|
||||
'uid' => $uid,
|
||||
'status' => 0,
|
||||
'is_fail' => 0
|
||||
];
|
||||
//抵扣券仅限官方店铺使用
|
||||
$isOfficialStore = true;
|
||||
foreach ($merchantCartList as $merchantCart) {
|
||||
if ($merchantCart['type_id'] != 22) {
|
||||
$isOfficialStore = false;
|
||||
}
|
||||
}
|
||||
if (!$isOfficialStore) {
|
||||
$ConsumptionWhere['type'] = 1;
|
||||
}
|
||||
|
||||
if ($isPlatformCard) {
|
||||
$platformConsumption = [];
|
||||
} else {
|
||||
$platformConsumption = Db::name('store_consumption_user')->where($ConsumptionWhere)->limit(100)->order('create_time', 'desc')
|
||||
->field('coupon_user_id,uid,coupon_title,coupon_price,balance,start_time,end_time')
|
||||
->select()->each(function ($item) {
|
||||
@ -670,45 +619,42 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
$allow_no_address = false;
|
||||
}
|
||||
|
||||
// 计算红包总金额
|
||||
$consumptionTotal = 0;
|
||||
$consumptionUsed = 0;
|
||||
$groupOrderPayPrice = 0;
|
||||
if ($consumption_id > 0 && $this->store_consumption_user) {
|
||||
if ($consumption_id > 0 && $this->store_consumption_user && $source == 103) {
|
||||
if ($this->store_consumption_user['type'] == 2 && $order_total_price >= 6) {
|
||||
if ($this->payType == 'balance') {
|
||||
throw new ValidateException('余额支付时,不能使用抵扣红包');
|
||||
}
|
||||
$consumptionTotal = bcdiv($order_total_price, 6, 2);
|
||||
}
|
||||
if ($this->store_consumption_user['type'] == 1) {
|
||||
$consumptionTotal = min($order_total_price, $this->balance);
|
||||
}
|
||||
foreach ($merchantCartList as $k => &$merchantCart) {
|
||||
$lastOrder = count($merchantCartList) == $k + 1;
|
||||
$orderPayPrice = 0;
|
||||
$orderConsumptionAmount = 0;
|
||||
foreach ($merchantCart['list'] as $key => &$cart) {
|
||||
$cart['total_price'] = bcadd($cart['total_price'], $cart['svip_discount'], 2);
|
||||
if ($consumptionTotal) {
|
||||
$lastProduct = count($merchantCart['list']) == $key + 1;
|
||||
$storeConsumptionUserDao = new StoreConsumptionUserDao();
|
||||
$storeConsumptionUserDao->groupOrderTotalPrice = $order_total_price;
|
||||
$storeConsumptionUserDao->orderProductPrice = $cart['total_price'];
|
||||
$storeConsumptionUserDao->profitRate = $cart['profit_rate'];
|
||||
$storeConsumptionUserDao->consumptionTotalAmount = $consumptionTotal;
|
||||
$storeConsumptionUserDao->consumptionUsed = $consumptionUsed;
|
||||
$storeConsumptionUserDao->isLast = $lastOrder && $lastProduct;
|
||||
if ($this->store_consumption_user['type'] == 2) {
|
||||
[$payPrice, $useAmount, $consumptionUsed] = $storeConsumptionUserDao->typeTwoByProduct();
|
||||
} else {
|
||||
[$payPrice, $useAmount, $consumptionUsed] = $storeConsumptionUserDao->typeOneByProduct();
|
||||
$consumptionTotal = min($consumptionTotal, $this->balance);
|
||||
}
|
||||
$groupOrderPayPrice = $order_total_price;
|
||||
foreach ($merchantCartList as $k => &$merchantCart) {
|
||||
$isLast = count($merchantCartList) == $k + 1;
|
||||
foreach ($merchantCart['list'] as &$cart) {
|
||||
$cart['total_price'] = bcadd($cart['total_price'], $cart['svip_discount'], 2);
|
||||
}
|
||||
|
||||
$orderPayPrice = $merchantCart['order']['total_price'];
|
||||
if ($consumptionTotal) {
|
||||
$storeConsumptionUserDao = new StoreConsumptionUserDao();
|
||||
$storeConsumptionUserDao->groupOrderTotalPrice = $groupOrderPayPrice;
|
||||
$storeConsumptionUserDao->orderTotalPrice = $orderPayPrice;
|
||||
$storeConsumptionUserDao->consumptionTotalAmount = $consumptionTotal;
|
||||
$storeConsumptionUserDao->isLast = $isLast;
|
||||
[$orderPayPrice, $groupOrderPayPrice, $useAmount, $consumptionTotal] = $storeConsumptionUserDao->calculateByOrder();
|
||||
$this->consumption_money = bcadd($this->consumption_money, $useAmount, 2);
|
||||
$this->balance = bcsub($this->balance, $useAmount, 2);
|
||||
}
|
||||
$cart['pay_price'] = $payPrice ?? $cart['total_price'];
|
||||
$cart['consumption_price'] = $useAmount ?? 0;
|
||||
$orderPayPrice = bcadd($orderPayPrice, $cart['pay_price'], 2);
|
||||
$orderConsumptionAmount = bcadd($orderConsumptionAmount, $cart['consumption_price'], 2);
|
||||
$groupOrderPayPrice = bcadd($groupOrderPayPrice, $cart['pay_price'], 2);
|
||||
}
|
||||
|
||||
if ($source == 105) {
|
||||
$this->consumption_money = bcsub($orderPayPrice, 2, 2);
|
||||
$orderConsumptionAmount = $this->consumption_money;
|
||||
$useAmount = $this->consumption_money;
|
||||
$orderPayPrice = '2.00';
|
||||
$groupOrderPayPrice = $orderPayPrice;
|
||||
$order_total_price = $orderPayPrice;
|
||||
@ -717,16 +663,13 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
}
|
||||
|
||||
unset($cart);
|
||||
$merchantCart['order']['consumption_money'] = $orderConsumptionAmount;
|
||||
$merchantCart['order']['consumption_money'] = $useAmount ?? '0.00';
|
||||
$merchantCart['order']['pay_price'] = $orderPayPrice;
|
||||
$merchantCart['order']['total_price'] = bcadd($merchantCart['order']['total_price'], $merchantCart['order']['svip_discount'], 2);
|
||||
$order_total_price = bcadd($order_total_price, $merchantCart['order']['svip_discount'], 2);
|
||||
}
|
||||
unset($merchantCart);
|
||||
$status = ($address || $order_model || $allow_no_address) ? ($noDeliver ? 'noDeliver' : 'finish') : 'noAddress';
|
||||
if ($isPickupCard) {
|
||||
$status = 'finish';
|
||||
}
|
||||
$order = $merchantCartList;
|
||||
$consumption_money = $this->consumption_money;
|
||||
$order_price = $groupOrderPayPrice;
|
||||
@ -775,7 +718,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
$order_model = $orderInfo['order_model'];
|
||||
$order_extend = $orderInfo['order_extend'];
|
||||
if ($pay_type == 'balance' && $orderInfo['source'] != 103 && $orderInfo['source'] != 105) {
|
||||
// throw new ValidateException('余额支付只能用于里海云仓');
|
||||
throw new ValidateException('余额支付只能用于里海云仓');
|
||||
}
|
||||
// 以下判断无意义,v2CartIdByOrderInfo 已经判断过收货地址或自提地址
|
||||
// if (!$orderInfo['order_delivery_status']) {
|
||||
@ -827,7 +770,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
if (($orderType == 98 || $orderType == 99) && count($merchantCartList) > 1) {
|
||||
throw new ValidateException('采购、委托商品不支持跨店购买');
|
||||
}
|
||||
if ($hasTake && $orderInfo['source'] != 999) {
|
||||
if ($hasTake) {
|
||||
app()->make(UserAddressValidate::class)->scene('take')->check($post);
|
||||
}
|
||||
|
||||
@ -861,7 +804,6 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
$total_extension_one = 0;
|
||||
$total_extension_two = 0;
|
||||
//计算佣金和赠送的优惠券
|
||||
$isPickupCard = $merchantCart['list'][0]['product']->isPickupCard();
|
||||
foreach ($merchantCart['list'] as &$cart) {
|
||||
$cartIds[] = $cart['cart_id'];
|
||||
$giveCouponIds = array_merge($giveCouponIds, $cart['product']['give_coupon_ids'] ?: []);
|
||||
@ -882,9 +824,6 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
} else if (isset($merchantCart['merchantCategory']['commission_rate']) && $merchantCart['merchantCategory']['commission_rate'] > 0) {
|
||||
$rate = bcmul($merchantCart['merchantCategory']['commission_rate'], 100, 4);
|
||||
}
|
||||
if ($isPickupCard) {
|
||||
$rate = 0;
|
||||
}
|
||||
$user_address = isset($address) ? ($address['province'] . $address['city'] . $address['district'] . $address['street'] . $address['village'] . $address['brigade'] . $address['detail']) : '';
|
||||
$user_address_code = isset($address) ? ($address['province_code'] . ',' . $address['city_code'] . ',' . $address['district_code'] . ',' . $address['street_code'] . ',' . $address['village_code'] . ',' . $address['brigade_id']) : '';
|
||||
//整理订单数据
|
||||
@ -902,8 +841,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
'spread_uid' => $spreadUid,
|
||||
'top_uid' => $topUid,
|
||||
'is_selfbuy' => $isSelfBuy,
|
||||
'real_name' => $merchantCart['order']['isTake'] ? $post['real_name'] ?? '' : ($address['real_name'] ?? ''),
|
||||
'user_phone' => $merchantCart['order']['isTake'] ? $post['phone'] ?? '' : ($address['phone'] ?? ''),
|
||||
'real_name' => $merchantCart['order']['isTake'] ? $post['real_name'] : ($address['real_name'] ?? ''),
|
||||
'user_phone' => $merchantCart['order']['isTake'] ? $post['phone'] : ($address['phone'] ?? ''),
|
||||
'user_address' => $user_address,
|
||||
'user_address_code' => $user_address_code,
|
||||
'cart_id' => implode(',', array_column($merchantCart['list'], 'cart_id')),
|
||||
@ -1063,8 +1002,19 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
'balance'=>0,'use_min_price'=>0,'order_id_set'=>'','create_time'=>date('Y-m-d H:i:s'),'start_time'=>date('Y-m-d H:i:s'),
|
||||
'end_time'=>date('Y-m-d H:i:s'),'use_time'=>date('Y-m-d H:i:s'),'type'=>1,'send_id'=>0,'status'=>1]);
|
||||
}else{
|
||||
$storeConsumptionUserDao = new StoreConsumptionUserDao();
|
||||
$storeConsumptionUserDao->reduce($groupOrder['consumption_id'], $groupOrder['consumption_money']);
|
||||
$store_consumption_user = Db::name('store_consumption_user')->where('uid', $uid)->where('coupon_user_id', $groupOrder['consumption_id'])->where('status', 0)->find();
|
||||
if ($store_consumption_user) {
|
||||
if ($store_consumption_user['type'] == 1) {
|
||||
if ($store_consumption_user['balance'] > $groupOrder['consumption_money']) {
|
||||
$balance = bcsub($store_consumption_user['balance'], $groupOrder['consumption_money'], 2);
|
||||
$balanceArr = ['balance' => $balance];
|
||||
Db::name('store_consumption_user')->where('coupon_user_id', $store_consumption_user['coupon_user_id'])->update($balanceArr);
|
||||
} else {
|
||||
$balanceArr = ['balance' => 0, 'status' => 1];
|
||||
Db::name('store_consumption_user')->where('coupon_user_id', $store_consumption_user['coupon_user_id'])->update($balanceArr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
app()->make(UserBillRepository::class)->decBill($user['uid'], 'consumption', 'deduction', [
|
||||
@ -1225,8 +1175,6 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
'cart_info' => json_encode($order_cart),
|
||||
'product_source_id' => $product_source_id,
|
||||
'product_mer_id' => $product_mer_id,
|
||||
'pay_price' => $cart['pay_price'],
|
||||
'consumption_price' => $cart['consumption_price'],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,6 @@ use app\common\model\store\order\StoreOrder;
|
||||
use app\common\model\store\order\StoreOrderInterest;
|
||||
use app\common\model\store\order\StoreRefundOrder;
|
||||
use app\common\model\store\product\PurchaseRecord;
|
||||
use app\common\model\system\merchant\FinancialRecord;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\repositories\BaseRepository;
|
||||
@ -86,7 +85,7 @@ class StoreOrderRepository extends BaseRepository
|
||||
/**
|
||||
* 支付类型
|
||||
*/
|
||||
const PAY_TYPE = ['balance', 'weixin', 'routine', 'h5', 'alipay', 'alipayQr', 'weixinQr', 'scrcu', 'creditBuy', 'merBalance'];
|
||||
const PAY_TYPE = ['balance', 'weixin', 'routine', 'h5', 'alipay', 'alipayQr', 'weixinQr', 'scrcu', 'creditBuy'];
|
||||
|
||||
const TYPE_SN_ORDER = 'wxo';
|
||||
const TYPE_SN_PRESELL = 'wxp';
|
||||
@ -118,9 +117,6 @@ class StoreOrderRepository extends BaseRepository
|
||||
if ($type === 'balance') {
|
||||
return $this->payBalance($user, $groupOrder);
|
||||
}
|
||||
if ($type === 'merBalance') {
|
||||
return $this->payMerBalance($user, $groupOrder);
|
||||
}
|
||||
|
||||
if (in_array($type, ['weixin', 'alipay'], true) && $isApp) {
|
||||
$type .= 'App';
|
||||
@ -169,45 +165,6 @@ class StoreOrderRepository extends BaseRepository
|
||||
Db::commit();
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error('余额支付失败'.$e->getMessage().'。line:'.$e->getLine().'。file:'.$e->getFile());
|
||||
throw new ValidateException('余额支付失败'.$e->getMessage());
|
||||
}
|
||||
|
||||
return app('json')->status('success', '余额支付成功', ['order_id' => $groupOrder['group_order_id']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param StoreGroupOrder $groupOrder
|
||||
* @return mixed
|
||||
* @author xaboy
|
||||
* @day 2020/6/9
|
||||
*/
|
||||
public function payMerBalance(User $user, StoreGroupOrder $groupOrder)
|
||||
{
|
||||
if (!systemConfig('yue_pay_status'))
|
||||
throw new ValidateException('未开启余额支付');
|
||||
$merchant = Merchant::where('uid', $user['uid'])->find();
|
||||
if (empty($merchant['mer_money']) || $merchant['mer_money'] < $groupOrder['pay_price'])
|
||||
throw new ValidateException('余额不足,请更换支付方式');
|
||||
Db::startTrans();
|
||||
try {
|
||||
$merchant->mer_money = bcsub($merchant->mer_money, $groupOrder['pay_price'], 2);
|
||||
$merchant->save();
|
||||
$userBillRepository = app()->make(UserBillRepository::class);
|
||||
$userBillRepository->decBill($merchant['uid'], 'mer_money', 'pay_product', [
|
||||
'link_id' => $groupOrder['group_order_id'],
|
||||
'status' => 1,
|
||||
'title' => '购买商品',
|
||||
'number' => $groupOrder['pay_price'],
|
||||
'mark' => '商户余额支付支付' . floatval($groupOrder['pay_price']) . '元购买商品',
|
||||
'balance' => $merchant->mer_money
|
||||
]);
|
||||
$this->paySuccess($groupOrder);
|
||||
Db::commit();
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
Log::error('余额支付失败'.$e->getMessage().'。line:'.$e->getLine().'。file:'.$e->getFile());
|
||||
throw new ValidateException('余额支付失败'.$e->getMessage());
|
||||
}
|
||||
|
||||
@ -260,16 +217,16 @@ class StoreOrderRepository extends BaseRepository
|
||||
$groupOrder->append(['orderList.orderProduct']);
|
||||
$flag = true;
|
||||
$profitsharing = [];
|
||||
$userMerchantRepository = app()->make(UserMerchantRepository::class);//商户用户表
|
||||
$storeOrderProfitsharingRepository = app()->make(StoreOrderProfitsharingRepository::class);//分账
|
||||
$userMerchantRepository = app()->make(UserMerchantRepository::class);
|
||||
$storeOrderProfitsharingRepository = app()->make(StoreOrderProfitsharingRepository::class);
|
||||
$uid = $groupOrder->uid;
|
||||
$i = 0;
|
||||
// $isVipCoupon = app()->make(StoreGroupOrderRepository::class)->isVipCoupon($groupOrder);
|
||||
//订单记录
|
||||
$storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);//订单操作
|
||||
$storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
|
||||
$svipDiscount = 0;
|
||||
$financeDao = new FinancialDao(); //商户财务申请提现
|
||||
$financeDao = new FinancialDao();
|
||||
foreach ($groupOrder->orderList as $_k => $order) {
|
||||
$isPickupCard = $order->source == 999;
|
||||
(new StoreActivityDao())->saveOrderProduct(2, $order);
|
||||
$order->paid = 1;
|
||||
$order->pay_time = $time;
|
||||
@ -280,7 +237,7 @@ class StoreOrderRepository extends BaseRepository
|
||||
$presell = false;
|
||||
//todo 等待付尾款
|
||||
if ($order->activity_type == 2) {
|
||||
$_make = app()->make(ProductPresellSkuRepository::class);//库存
|
||||
$_make = app()->make(ProductPresellSkuRepository::class);
|
||||
if ($order->orderProduct[0]['cart_info']['productPresell']['presell_type'] == 2) {
|
||||
$order->status = 10;
|
||||
$presell = true;
|
||||
@ -291,7 +248,7 @@ class StoreOrderRepository extends BaseRepository
|
||||
} else if ($order->activity_type == 4) {
|
||||
$order->status = 9;
|
||||
$order->save();
|
||||
$group_buying_id = app()->make(ProductGroupBuyingRepository::class)->create( //平团
|
||||
$group_buying_id = app()->make(ProductGroupBuyingRepository::class)->create(
|
||||
$groupOrder->user,
|
||||
$order->orderProduct[0]['cart_info']['activeSku']['product_group_id'],
|
||||
$order->orderProduct[0]['activity_id'],
|
||||
@ -331,9 +288,10 @@ class StoreOrderRepository extends BaseRepository
|
||||
'user_type' => $storeOrderStatusRepository::U_TYPE_USER,
|
||||
];
|
||||
|
||||
//TODO 成为推广员
|
||||
foreach ($order->orderProduct as $product) {
|
||||
if ($flag && $product['cart_info']['product']['is_gift_bag']) {
|
||||
app()->make(UserRepository::class)->promoter($order->uid); //推广
|
||||
app()->make(UserRepository::class)->promoter($order->uid);
|
||||
$flag = false;
|
||||
}
|
||||
}
|
||||
@ -346,50 +304,111 @@ class StoreOrderRepository extends BaseRepository
|
||||
$financeDao->order = $order;
|
||||
$financeDao->user = $groupOrder->user;
|
||||
$financialType = $presell ? 'order_presell' : 'order';
|
||||
// 平台收入流水账单数据
|
||||
$financeDao->platformIn($order->total_price, $financialType);
|
||||
if ($order->consumption_money > 0) {
|
||||
// 平台支出优惠金额
|
||||
$financeDao->platformOut($order->consumption_money, 'platform_consumption');
|
||||
}
|
||||
// 商户流水账单数据
|
||||
$financeDao->setData($order->pay_price, $financialType, 1, $presell ? 2 : 1);
|
||||
|
||||
$_payPrice = bcsub($order->pay_price, bcadd($order['extension_one'], $order['extension_two'], 3), 2);
|
||||
$orderValidAmount = bcsub($order->total_price, bcadd($order['extension_one'], $order['extension_two'], 3), 2);
|
||||
|
||||
// 平台支出推广费
|
||||
$promoter = $order->merchant->promoter();
|
||||
$promoterCommission = bcmul($orderValidAmount, 0.003, 2);
|
||||
if (!empty($promoter) && $promoterCommission > 0) {
|
||||
$financeDao->user = $promoter;
|
||||
$financeDao->platformOut($promoterCommission, 'commission_to_promoter');
|
||||
}
|
||||
|
||||
// 平台收入手续费
|
||||
$financeDao->user = $groupOrder->user;
|
||||
$commission_rate = bcdiv((string)$order['commission_rate'],'100',6);
|
||||
$platformCommission = bcmul($orderValidAmount, (string)$commission_rate, 2);
|
||||
if ($commission_rate > 0 && $platformCommission > 0) {
|
||||
$orderValidAmount = bcsub($orderValidAmount, $platformCommission, 2);
|
||||
if ($promoterCommission > 0 && !empty($promoter)) {
|
||||
$platformCommission = bcsub($platformCommission, $promoterCommission, 2);
|
||||
}
|
||||
$financeDao->platformIn($platformCommission, 'commission_to_platform', $order['mer_id']);
|
||||
}
|
||||
|
||||
if ($orderValidAmount > 0) {
|
||||
if ($order->source == 103) {
|
||||
$_payPrice = $order->procure_price;
|
||||
$financeDao->publicOut($_payPrice, 'supply_chain');
|
||||
//市级供应链
|
||||
$product_mer_id = Db::name('store_order_product')->where('order_id', $order->order_id)->value('product_mer_id');
|
||||
if ($product_mer_id) {
|
||||
$financeDao->publicOut($_payPrice, 'order', $product_mer_id);
|
||||
//市级供应链押金计算
|
||||
if ($_payPrice > 0) {
|
||||
/** @var MerchantRepository $merchantRepo */
|
||||
$merchantRepo = app()->make(MerchantRepository::class);//商户
|
||||
$merchantRepo->merId = $order['mer_id'];
|
||||
$merchantRepo = app()->make(MerchantRepository::class);
|
||||
$merchantRepo->merId = $product_mer_id;
|
||||
$merchantRepo->forceMargin = false;
|
||||
[$orderValidAmount, $financeDao] = $merchantRepo->deductDeposit($orderValidAmount, $order, $financeDao);
|
||||
[$_payCityPrice, $financeDao] = $merchantRepo->deductDeposit($_payPrice, $order, $financeDao);
|
||||
}
|
||||
|
||||
// 商户收入金额
|
||||
$financeDao->platformOut($orderValidAmount, 'merchant_order', $order['mer_id']);
|
||||
if (isset($_payCityPrice)) {
|
||||
$financeDao->platformOut($_payCityPrice, 'order_true', $product_mer_id);
|
||||
if (!$is_combine) {
|
||||
app()->make(MerchantRepository::class)->addLockMoney($order->mer_id, 'order', $order->order_id, $orderValidAmount);
|
||||
app()->make(MerchantRepository::class)->addLockMoney($product_mer_id, 'order', $order->order_id, $_payCityPrice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//计算手续费
|
||||
$_order_rate = bcsub($order->pay_price, $_payPrice, 2);
|
||||
|
||||
//计算镇级供应链云仓实际获得金额
|
||||
// 服务团队佣金统一由新供销平台结算
|
||||
// if ($_order_rate > 0) {
|
||||
// $commission_rate = bcdiv(12, 100, 2);
|
||||
// $_payPrice = bcmul($_order_rate, $commission_rate, 2);
|
||||
// } else {
|
||||
// $_payPrice = 0;
|
||||
// }
|
||||
} else {
|
||||
$_payPrice = $order->pay_price;
|
||||
$_order_rate = 0;
|
||||
|
||||
//平台手续费
|
||||
if ($order['commission_rate'] > 0) {
|
||||
|
||||
$commission_rate = ($order['commission_rate'] / 100);
|
||||
|
||||
$_order_rate = bcmul($_payPrice, $commission_rate, 2);
|
||||
|
||||
$_payPrice = bcsub($_payPrice, $_order_rate, 2);
|
||||
// 结算各镇 小组佣金
|
||||
// event('order.paySuccessOrder', compact('order', '_order_rate'));
|
||||
}
|
||||
}
|
||||
|
||||
// bcsub($order->pay_price, bcadd($order['extension_one'], $order['extension_two'], 3), 2);
|
||||
// if ($presell) {
|
||||
// if (isset($order->orderProduct[0]['cart_info']['presell_extension_one']) && $order->orderProduct[0]['cart_info']['presell_extension_one'] > 0) {
|
||||
// $_payPrice = bcadd($_payPrice, $order->orderProduct[0]['cart_info']['presell_extension_one'], 2);
|
||||
// }
|
||||
// if (isset($order->orderProduct[0]['cart_info']['presell_extension_two']) && $order->orderProduct[0]['cart_info']['presell_extension_two'] > 0) {
|
||||
// $_payPrice = bcadd($_payPrice, $order->orderProduct[0]['cart_info']['presell_extension_two'], 2);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
if (!$presell) {
|
||||
if ($order['commission_rate'] > 0 || $order->source == 103) {
|
||||
//支出手续费
|
||||
$financeDao->publicOut($_order_rate, 'order_charge');
|
||||
}
|
||||
//押金计算
|
||||
if ($_payPrice > 0) {
|
||||
/** @var MerchantRepository $merchantRepo */
|
||||
$merchantRepo = app()->make(MerchantRepository::class);
|
||||
$merchantRepo->merId = $order->mer_id;
|
||||
$merchantRepo->forceMargin = false;
|
||||
[$_payCityPrice, $financeDao] = $merchantRepo->deductDeposit($_payPrice, $order, $financeDao);
|
||||
}
|
||||
if ($order->source == 103) {
|
||||
$financeDao->publicOut($_payPrice, 'commission_to_cloud_warehouse');
|
||||
} else {
|
||||
$financeDao->platformOut($_payPrice, 'order_true');
|
||||
}
|
||||
|
||||
|
||||
// if ($order->platform_coupon_price > 0) {
|
||||
// $finance[] = [
|
||||
// 'order_id' => $order->order_id,
|
||||
// 'order_sn' => $order->order_sn,
|
||||
// 'user_info' => $groupOrder->user->nickname,
|
||||
// 'user_id' => $uid,
|
||||
// 'financial_type' => $isVipCoupon ? 'order_svip_coupon' : 'order_platform_coupon',
|
||||
// 'financial_pm' => 0,
|
||||
// 'type' => 1,
|
||||
// 'number' => $order->platform_coupon_price,
|
||||
// 'mer_id' => $order->mer_id,
|
||||
// 'financial_record_sn' => $financeSn . ($i++)
|
||||
// ];
|
||||
// $_payPrice = bcadd($_payPrice, $order->platform_coupon_price, 2);
|
||||
// }
|
||||
if (!$is_combine) {
|
||||
app()->make(MerchantRepository::class)->addLockMoney($order->mer_id, 'order', $order->order_id, $_payPrice);
|
||||
}
|
||||
}
|
||||
if ($is_combine) {
|
||||
$profitsharing[] = [
|
||||
'profitsharing_sn' => $storeOrderProfitsharingRepository->getOrderSn(),
|
||||
@ -412,17 +431,9 @@ class StoreOrderRepository extends BaseRepository
|
||||
], $order->mer_id);
|
||||
//自动打印订单
|
||||
$this->autoPrinter($order->order_id, $order->mer_id);
|
||||
|
||||
//判断是否是平台购物卡
|
||||
if ($order->orderProduct[0]->product->isPlatformCard() || $isPickupCard) {
|
||||
//购物卡自动发货
|
||||
$deliveryData = [
|
||||
'delivery_type' => 3,
|
||||
'remark' => '',
|
||||
'delivery_name' => '',
|
||||
'delivery_id' => '',
|
||||
];
|
||||
$this->runDelivery($order['order_id'], $order['mer_id'], $deliveryData, ['is_split' => 0, 'split' => []], 'delivery');
|
||||
if ($order['pay_price'] > 0 && $order['source'] == 103) {
|
||||
// "惠农供销,谱写数字新篇章"活动首单分润,商户和村、小组合伙人
|
||||
$financeDao = (new CommissionDao())->firstOrderCommission($order, $financeDao);
|
||||
}
|
||||
}
|
||||
//分销判断
|
||||
@ -639,8 +650,8 @@ class StoreOrderRepository extends BaseRepository
|
||||
}
|
||||
$where['activity_type'] = $product_type;
|
||||
if ($source == 103) {
|
||||
$where['activity_type'] = [0, 2, 98];
|
||||
$where['source'] = [0, 2, 103,105, 999];
|
||||
$where['activity_type'] = [0, 98];
|
||||
$where['source'] = [0, 2, 103,105];
|
||||
}
|
||||
$noComment = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(4))->where($where)->where('StoreOrder.is_del', 0)->count();
|
||||
$noPay = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(1))->whereRaw("(StoreOrder.paid=0 and StoreOrder.pay_type!=8) or (StoreOrder.paid=1 and StoreOrder.pay_type=8 and StoreOrder.status=2)")->where($where)->where('StoreOrder.is_del', 0)->count();
|
||||
@ -648,7 +659,7 @@ class StoreOrderRepository extends BaseRepository
|
||||
$noDeliver = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(3))->where($where)->where('StoreOrder.is_del', 0)->fetchSql(false)->count();
|
||||
$noComment = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(4))->where($where)->where('StoreOrder.is_del', 0)->fetchSql(false)->count();
|
||||
$done = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(5))->where($where)->where('StoreOrder.is_del', 0)->fetchSql(false)->count();
|
||||
$refund = StoreRefundOrder::alias('t1')->join('store_order t2', 't1.order_id=t2.order_id')->where('t1.uid', $uid)->whereIn('t1.status', [0, 1, 2])->where('t2.activity_type', $product_type)->count();
|
||||
$refund = StoreRefundOrder::alias('t1')->join('store_order t2', 't1.order_id=t2.order_id')->where('t1.uid', $uid)->where('t1.status', 3)->where('t2.activity_type', $product_type)->count();
|
||||
$orderPrice = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(8))->where($where)->where('StoreOrder.is_del', 0)->fetchSql(false)->sum('pay_price');
|
||||
$orderCount = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($where)->where('StoreOrder.is_del', 0)->fetchSql(false)->count();
|
||||
return compact('noComment', 'done', 'refund', 'noDeliver', 'noPay', 'noPostage', 'orderPrice', 'orderCount');
|
||||
@ -794,26 +805,6 @@ class StoreOrderRepository extends BaseRepository
|
||||
// 'number' => $order->extension_two,
|
||||
// ], $order->mer_id);
|
||||
}
|
||||
|
||||
$promoterCommission = FinancialRecord::where('order_id', $order['order_id'])
|
||||
->where('financial_type', 'commission_to_promoter')
|
||||
->field('user_id,number')
|
||||
->find();
|
||||
if (!empty($promoterCommission)) {
|
||||
$promoter = User::where('uid', $promoterCommission['user_id'])->find();
|
||||
if (!empty($promoter)) {
|
||||
$balance = bcadd($promoter->now_money, $promoterCommission['number'], 2);
|
||||
$promoter->save(['now_money' => $balance]);
|
||||
$userBillRepository->incBill($promoterCommission['user_id'], 'brokerage', 'order_one', [
|
||||
'link_id' => $order['order_id'],
|
||||
'status' => 1,
|
||||
'title' => '获得推广佣金',
|
||||
'number' => $promoterCommission['number'],
|
||||
'mark' => $order->merchant['mer_name'] . '成功销售' . floatval($order['pay_price']) . '元,奖励推广佣金' . floatval($promoterCommission['number']),
|
||||
'balance' => 0
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -837,19 +828,6 @@ class StoreOrderRepository extends BaseRepository
|
||||
$order->interest->save();
|
||||
}
|
||||
$order->save();
|
||||
|
||||
if ($order->uid != $order->merchant->uid && !$order->orderProduct[0]->product->isPlatformCard()) {
|
||||
$refundPrice = StoreRefundOrder::where('order_id', $order['order_id'])->where('status', '<>', -1)->sum('refund_price');
|
||||
$money = bcsub($order->total_price, bcadd($order['extension_one'], $order['extension_two'], 3), 2);
|
||||
$money = bcsub($money, $refundPrice, 2);
|
||||
//订单确认收货,增加商户销售金额
|
||||
Merchant::where('mer_id', $order->mer_id)->update(['sale_amount' => Db::raw('sale_amount+' . $money)]);
|
||||
//订单确认收货,增加商户采购金额
|
||||
$merId = Merchant::where('uid', $order->uid)->value('mer_id');
|
||||
if (!empty($merId)) {
|
||||
Merchant::where('mer_id', $merId)->update(['purchase_amount' => Db::raw('purchase_amount+' . $money)]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1390,7 +1368,6 @@ class StoreOrderRepository extends BaseRepository
|
||||
if ($order['is_virtual'] && $data['delivery_type'] != 3)
|
||||
throw new ValidateException('虚拟商品只能虚拟发货');
|
||||
//订单记录
|
||||
/** @var StoreOrderStatusRepository $statusRepository */
|
||||
$statusRepository = app()->make(StoreOrderStatusRepository::class);
|
||||
switch ($data['delivery_type']) {
|
||||
case 1:
|
||||
@ -1432,8 +1409,6 @@ class StoreOrderRepository extends BaseRepository
|
||||
'change_message' => $change_message,
|
||||
'change_type' => $change_type,
|
||||
];
|
||||
$statusRepository->adminId = $order['mer_id'];
|
||||
$statusRepository->adminNickname = $order->merchant['nickname'];
|
||||
if ($service_id) {
|
||||
$statusRepository->createServiceLog($service_id, $orderStatus);
|
||||
} else {
|
||||
@ -2519,9 +2494,6 @@ class StoreOrderRepository extends BaseRepository
|
||||
public function childrenList($id, $merId)
|
||||
{
|
||||
$data = $this->dao->get($id);
|
||||
if (empty($data)) {
|
||||
return [];
|
||||
}
|
||||
$query = $this->dao->getSearch([])->with(['orderProduct'])->where('order_id', '<>', $id);
|
||||
if ($merId) $query->where('mer_id', $merId);
|
||||
if ($data['main_id']) {
|
||||
|
@ -100,8 +100,6 @@ class StoreOrderStatusRepository extends BaseRepository
|
||||
const ORDER_DELIVERY_CITY_REFUND = 'delivery_5_10';
|
||||
const ORDER_DELIVERY_CITY_REFUNDING = 'delivery_5_9';
|
||||
|
||||
public $adminId;
|
||||
public $adminNickname;
|
||||
|
||||
/**
|
||||
* StoreOrderStatusRepository constructor.
|
||||
@ -136,15 +134,9 @@ class StoreOrderStatusRepository extends BaseRepository
|
||||
public function createAdminLog(array $data)
|
||||
{
|
||||
$request = request();
|
||||
if ($request->hasMacro('userType')) {
|
||||
$data['user_type'] = $request->userType();
|
||||
$data['uid'] = $data['user_type'] == 1 ? $request->uid() : $request->adminId();
|
||||
$data['nickname'] = $data['user_type'] == 1 ? $request->userInfo()->real_name : $request->adminInfo()->real_name;
|
||||
} else {
|
||||
$data['user_type'] = 3;
|
||||
$data['uid'] = $this->adminId;
|
||||
$data['nickname'] = $this->adminNickname;
|
||||
}
|
||||
return $this->dao->create($data);
|
||||
}
|
||||
|
||||
|
@ -489,17 +489,6 @@ class StoreOtherOrderCreateRepository extends StoreOtherOrderRepository
|
||||
$extend['bank_info']=$courierData['data'];
|
||||
}
|
||||
}
|
||||
if ($pay_type == 12) {
|
||||
$extend = [
|
||||
'bank_info' => [
|
||||
'company_name' => '泸州里海农业科技有限公司',
|
||||
'corporate_account' => '22170201040004168',
|
||||
'corporate_bank' => '中国农业银行股份有限公司泸州石洞支行',
|
||||
'corporate_bank_address' => '泸州市江阳区分水岭镇振兴路03号1-2-1号',
|
||||
],
|
||||
'corporate_voucher' => '',
|
||||
];
|
||||
}
|
||||
$merchantCartList = $orderInfo['order'];
|
||||
$cartSpread = 0;
|
||||
$hasTake = false;
|
||||
|
@ -12,16 +12,10 @@
|
||||
namespace app\common\repositories\store\order;
|
||||
|
||||
use app\common\dao\store\order\StoreOrderOtherDao;
|
||||
use app\common\dao\system\financial\FinancialDao;
|
||||
use app\common\model\store\order\StoreGroupOrder;
|
||||
use app\common\model\store\order\StoreGroupOrderOther;
|
||||
use app\common\model\store\order\StoreOrder;
|
||||
use app\common\model\store\order\StoreOrderInterestOther;
|
||||
use app\common\model\store\order\StoreOrderOther;
|
||||
use app\common\model\store\order\StoreRefundOrder;
|
||||
use app\common\model\store\order\StoreRefundOrderOther;
|
||||
use app\common\model\system\merchant\FinancialRecord;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\model\user\User;
|
||||
use app\common\repositories\BaseRepository;
|
||||
use app\common\repositories\store\product\ProductRepository;
|
||||
@ -177,7 +171,6 @@ class StoreOtherOrderRepository extends BaseRepository
|
||||
//订单记录
|
||||
$storeOrderStatusRepository = app()->make(StoreOrderStatusOtherRepository::class);
|
||||
$svipDiscount = 0;
|
||||
$financeDao = new FinancialDao();
|
||||
foreach ($groupOrder->orderList as $_k => $order) {
|
||||
if($groupOrder->order_extend){
|
||||
if($order->order_extend){
|
||||
@ -212,18 +205,21 @@ class StoreOtherOrderRepository extends BaseRepository
|
||||
'user_type' => $storeOrderStatusRepository::U_TYPE_USER,
|
||||
];
|
||||
|
||||
$financeDao->order = $order;
|
||||
$financeDao->user = $groupOrder->user;
|
||||
$financialType = $presell ? 'order_presell' : 'order';
|
||||
// 平台收入流水账单数据
|
||||
$financeDao->platformIn($order->total_price, $financialType);
|
||||
if ($order->consumption_money > 0) {
|
||||
// 平台支出优惠金额
|
||||
$financeDao->platformOut($order->consumption_money, 'platform_consumption');
|
||||
}
|
||||
// 商户流水账单数据
|
||||
$finance[] = [
|
||||
'order_id' => $order->order_id,
|
||||
'order_sn' => $order->order_sn,
|
||||
'user_info' => $groupOrder->user->nickname,
|
||||
'user_id' => $uid,
|
||||
'financial_type' => $presell ? 'order_presell' : 'order',
|
||||
'financial_pm' => 1,
|
||||
'type' => $presell ? 2 : 1,
|
||||
'number' => $order->pay_price,
|
||||
'mer_id' => $order->mer_id,
|
||||
'financial_record_sn' => $financeSn . ($i++)
|
||||
];
|
||||
|
||||
$_payPrice = bcsub($order->pay_price, bcadd($order['extension_one'], $order['extension_two'], 3), 2);
|
||||
$orderValidAmount = bcsub($order->total_price, bcadd($order['extension_one'], $order['extension_two'], 3), 2);
|
||||
if ($presell) {
|
||||
if (isset($order->orderProduct[0]['cart_info']['presell_extension_one']) && $order->orderProduct[0]['cart_info']['presell_extension_one'] > 0) {
|
||||
$_payPrice = bcadd($_payPrice, $order->orderProduct[0]['cart_info']['presell_extension_one'], 2);
|
||||
@ -233,41 +229,72 @@ class StoreOtherOrderRepository extends BaseRepository
|
||||
}
|
||||
}
|
||||
|
||||
// 平台支出推广费
|
||||
$promoter = $order->merchant->promoter();
|
||||
$promoterCommission = bcmul($orderValidAmount, 0.003, 2);
|
||||
if (!empty($promoter) && $promoterCommission > 0) {
|
||||
$financeDao->user = $promoter;
|
||||
$financeDao->platformOut($promoterCommission, 'commission_to_promoter');
|
||||
}
|
||||
$_order_rate = 0;
|
||||
|
||||
// 平台收入手续费
|
||||
$financeDao->user = $groupOrder->user;
|
||||
$commission_rate = bcdiv((string)$order['commission_rate'],'100',6);
|
||||
$platformCommission = bcmul($orderValidAmount, (string)$commission_rate, 2);
|
||||
if ($commission_rate > 0 && $platformCommission > 0) {
|
||||
$orderValidAmount = bcsub($orderValidAmount, $platformCommission, 2);
|
||||
if ($promoterCommission > 0 && !empty($promoter)) {
|
||||
$platformCommission = bcsub($platformCommission, $promoterCommission, 2);
|
||||
}
|
||||
$financeDao->platformIn($platformCommission, 'commission_to_platform', $order['mer_id']);
|
||||
//平台手续费
|
||||
if ($order['commission_rate'] > 0) {
|
||||
|
||||
$commission_rate = ($order['commission_rate'] / 100);
|
||||
|
||||
$_order_rate = bcmul($_payPrice, $commission_rate, 2);
|
||||
|
||||
$_payPrice = bcsub($_payPrice, $_order_rate, 2);
|
||||
// 结算各镇 小组佣金
|
||||
event('order.paySuccessOrderOther', compact('order', '_order_rate'));
|
||||
}
|
||||
|
||||
if (!$presell) {
|
||||
|
||||
if ($order['commission_rate'] > 0) {
|
||||
$finance[] = [
|
||||
'order_id' => $order->order_id,
|
||||
'order_sn' => $order->order_sn,
|
||||
'user_info' => $groupOrder->user->nickname,
|
||||
'user_id' => $uid,
|
||||
'financial_type' => 'order_charge',
|
||||
'financial_pm' => 0,
|
||||
'type' => 1,
|
||||
'number' => $_order_rate,
|
||||
'mer_id' => $order->mer_id,
|
||||
'financial_record_sn' => $financeSn . ($i++)
|
||||
];
|
||||
}
|
||||
//押金计算
|
||||
if ($orderValidAmount > 0) {
|
||||
if ($_payPrice > 0) {
|
||||
/** @var MerchantRepository $merchantRepo */
|
||||
$merchantRepo = app()->make(MerchantRepository::class);
|
||||
$merchantRepo->merId = $order['mer_id'];
|
||||
$merchantRepo->merId = $order->mer_id;
|
||||
$merchantRepo->forceMargin = false;
|
||||
[$orderValidAmount, $financeDao] = $merchantRepo->deductDeposit($orderValidAmount, $order, $financeDao);
|
||||
}
|
||||
// 商户收入金额
|
||||
$financeDao->platformOut($orderValidAmount, 'merchant_order', $order['mer_id']);
|
||||
if (!$is_combine) {
|
||||
app()->make(MerchantRepository::class)->addLockMoney($order->mer_id, 'order', $order->order_id, $orderValidAmount);
|
||||
[$_payPrice, $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' => $_payPrice,
|
||||
'mer_id' => $order->mer_id,
|
||||
'financial_record_sn' => $financeSn . ($i++)
|
||||
];
|
||||
|
||||
if ($order->platform_coupon_price > 0) {
|
||||
$finance[] = [
|
||||
'order_id' => $order->order_id,
|
||||
'order_sn' => $order->order_sn,
|
||||
'user_info' => $groupOrder->user->nickname,
|
||||
'user_id' => $uid,
|
||||
'financial_type' => $isVipCoupon ? 'order_svip_coupon' : 'order_platform_coupon',
|
||||
'financial_pm' => 0,
|
||||
'type' => 1,
|
||||
'number' => $order->platform_coupon_price,
|
||||
'mer_id' => $order->mer_id,
|
||||
'financial_record_sn' => $financeSn . ($i++)
|
||||
];
|
||||
// $_payPrice = bcadd($_payPrice, $order->platform_coupon_price, 2);
|
||||
}
|
||||
// if (!$is_combine) {
|
||||
// app()->make(MerchantRepository::class)->addLockMoney($order->mer_id, 'order', $order->order_id, $_payPrice);
|
||||
// }
|
||||
@ -527,34 +554,14 @@ class StoreOtherOrderRepository extends BaseRepository
|
||||
public function takeAfter(StoreOrderOther $order, ?User $user)
|
||||
{
|
||||
Db::transaction(function () use ($user, $order) {
|
||||
if ($user && $order->pay_type != StoreGroupOrder::PAY_TYPE_CREDIT_BUY) {
|
||||
$this->computed($order, $user);
|
||||
}
|
||||
Queue::push(SendSmsJob::class, ['tempId' => 'ORDER_TAKE_SUCCESS', 'id' => $order->order_id]);
|
||||
Queue::push(SendSmsJob::class, ['tempId' => 'ADMIN_TAKE_DELIVERY_CODE', 'id' => $order->order_id]);
|
||||
if ($order->pay_type != StoreGroupOrder::PAY_TYPE_CREDIT_BUY) {
|
||||
app()->make(MerchantRepository::class)->computedSupplyLockMoney($order);
|
||||
}
|
||||
|
||||
if (!empty($order->interest) && $order->interest->status == StoreOrderInterestOther::STATUS_UNSETTLED) {
|
||||
$order->interest->start_time = date('Y-m-d H:i:s', strtotime("+{$order->interest->settle_cycle} days"));
|
||||
$order->interest->save();
|
||||
}
|
||||
$order->save();
|
||||
|
||||
if ($order->uid != $order->merchant->uid && !$order->orderProduct[0]->product->isPlatformCard()) {
|
||||
$refundPrice = StoreRefundOrderOther::where('order_id', $order['order_id'])->where('status', '<>', -1)->sum('refund_price');
|
||||
$money = bcsub($order->total_price, bcadd($order['extension_one'], $order['extension_two'], 3), 2);
|
||||
$money = bcsub($money, $refundPrice, 2);
|
||||
//订单确认收货,增加商户销售金额
|
||||
Merchant::where('mer_id', $order->mer_id)->update(['sale_amount' => Db::raw('sale_amount+' . $money)]);
|
||||
//订单确认收货,增加商户采购金额
|
||||
$merId = Merchant::where('uid', $order->uid)->value('mer_id');
|
||||
if (!empty($merId)) {
|
||||
Merchant::where('mer_id', $merId)->update(['purchase_amount' => Db::raw('purchase_amount+' . $money)]);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -1084,9 +1091,6 @@ class StoreOtherOrderRepository extends BaseRepository
|
||||
'spread' => function ($query) {
|
||||
$query->field('uid,nickname,avatar');
|
||||
},
|
||||
'merchant' => function ($query) {
|
||||
$query->field('mer_id,mer_name');
|
||||
},
|
||||
]
|
||||
);
|
||||
if (!$res) throw new ValidateException('数据不存在');
|
||||
@ -1276,12 +1280,10 @@ class StoreOtherOrderRepository extends BaseRepository
|
||||
'order_charge_lv'=>$item->merchant->commission_rate?round($item->merchant->commission_rate,2):0,
|
||||
];
|
||||
if(in_array($status,[4,5])){
|
||||
$merchant = Db::name('merchant')->where('mer_id',$item['mer_id'])->field('mer_id,mer_name,is_trader,financial_bank,auto_margin_rate,commission_rate')->find();
|
||||
$item['merchant']= Db::name('merchant')->where('mer_id',$item['mer_id'])->field('mer_id,mer_name,is_trader,financial_bank,auto_margin_rate,commission_rate')->find();
|
||||
}else{
|
||||
$merchant = Db::name('merchant')->where('uid',$item['uid'])->where('status',1)->field('mer_id,mer_name,is_trader,financial_bank,auto_margin_rate,commission_rate')->find();
|
||||
$item['merchant']= Db::name('merchant')->where('uid',$item['uid'])->where('status',1)->field('mer_id,mer_name,is_trader,financial_bank,auto_margin_rate,commission_rate')->find();
|
||||
}
|
||||
$merchant['financial_bank'] = !empty($merchant['financial_bank']) ? json_decode($merchant['financial_bank'], true) : [];
|
||||
$item['merchant'] = $merchant;
|
||||
});
|
||||
return compact('count', 'list');
|
||||
}
|
||||
@ -1904,26 +1906,4 @@ class StoreOtherOrderRepository extends BaseRepository
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function computed(StoreOrderOther $order, User $user)
|
||||
{
|
||||
/** @var UserBillRepository $userBillRepository */
|
||||
$userBillRepository = app()->make(UserBillRepository::class);
|
||||
$promoterCommission = FinancialRecord::where('order_id', $order['order_id'])
|
||||
->where('financial_type', 'promoter_commission')
|
||||
->column('user_id,number');
|
||||
if (!empty($promoterCommission)) {
|
||||
$userBillRepository->incBill($promoterCommission['user_id'], 'brokerage', 'order_one', [
|
||||
'link_id' => $order['order_id'],
|
||||
'status' => 0,
|
||||
'title' => '获得推广佣金',
|
||||
'number' => $promoterCommission['number'],
|
||||
'mark' => $order->merchant['mer_name'] . '成功销售' . floatval($order['pay_price']) . '元,奖励推广佣金' . floatval($promoterCommission['number']),
|
||||
'balance' => 0
|
||||
]);
|
||||
$balance = bcadd($user->now_money, $promoterCommission['number'], 2);
|
||||
$user->save(['now_money' => $balance]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,17 +16,14 @@ namespace app\common\repositories\store\order;
|
||||
|
||||
use app\common\dao\store\consumption\CommissionDao;
|
||||
use app\common\dao\store\consumption\StoreConsumptionUserDao;
|
||||
use app\common\dao\store\order\StoreOrderOtherDao;
|
||||
use app\common\dao\store\order\StoreRefundOrderDao;
|
||||
use app\common\dao\store\StoreActivityOrderDao;
|
||||
use app\common\dao\system\financial\FinancialDao;
|
||||
use app\common\model\store\order\StoreGroupOrder;
|
||||
use app\common\model\store\order\StoreOrder;
|
||||
use app\common\model\store\order\StoreRefundOrder;
|
||||
use app\common\model\store\product\CloudProduct;
|
||||
use app\common\model\store\StoreActivityOrderProduct;
|
||||
use app\common\model\system\merchant\FinancialRecord;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\repositories\BaseRepository;
|
||||
use app\common\repositories\store\product\ProductRepository;
|
||||
use app\common\repositories\system\merchant\FinancialRecordRepository;
|
||||
@ -245,14 +242,23 @@ class StoreRefundOrderRepository extends BaseRepository
|
||||
$productRefundPrices = app()->make(StoreRefundProductRepository::class)->userRefundPrice($products->column('order_product_id'));
|
||||
$totalPostage = 0;
|
||||
$totalRefundPrice = 0;
|
||||
$realPriceTotal = 0;
|
||||
$consumptionTotal = 0;
|
||||
foreach ($products as $k => $product) {
|
||||
$consumptionTotal = bcadd($consumptionTotal, $product['consumption_price'], 2);
|
||||
$isLast = count($products->toArray()) == ($k + 1);
|
||||
$storeConsumptionUserDao = new StoreConsumptionUserDao();
|
||||
$storeConsumptionUserDao->orderTotalPrice = $order['total_price'];
|
||||
$storeConsumptionUserDao->orderPayPrice = $order['pay_price'];
|
||||
$storeConsumptionUserDao->orderProductPrice = $product['product_price'];
|
||||
$storeConsumptionUserDao->realPriceTotal = $realPriceTotal;
|
||||
$storeConsumptionUserDao->isLast = $isLast;
|
||||
[$realPrice, $realPriceTotal, $consumptionPrice] = $storeConsumptionUserDao->calculate();
|
||||
$consumptionTotal = bcadd($consumptionTotal, $consumptionPrice, 2);
|
||||
$productRefundPrice = $productRefundPrices[$product['order_product_id']] ?? [];
|
||||
$postagePrice = (!$order->status || $order->status == 9) ? bcsub($product['postage_price'], $productRefundPrice['refund_postage'] ?? 0, 2) : 0;
|
||||
$refundPrice = 0;
|
||||
if ($product['pay_price'] > 0) {
|
||||
$refundPrice = bcsub($product['pay_price'], bcsub($productRefundPrice['refund_price'] ?? 0,$productRefundPrice['refund_postage']??0 ,2), 2);
|
||||
if ($realPrice > 0) {
|
||||
$refundPrice = bcsub($realPrice, bcsub($productRefundPrice['refund_price'] ?? 0,$productRefundPrice['refund_postage']??0 ,2), 2);
|
||||
}
|
||||
$totalPostage = bcadd($totalPostage, $postagePrice, 2);
|
||||
$totalRefundPrice = bcadd($totalRefundPrice, $refundPrice, 2);
|
||||
@ -283,8 +289,12 @@ class StoreRefundOrderRepository extends BaseRepository
|
||||
$productRefundPrices = app()->make(StoreRefundProductRepository::class)->userRefundPrice($products->column('order_product_id'));
|
||||
$product = $products[0];
|
||||
$productRefundPrice = $productRefundPrices[$product['order_product_id']] ?? [];
|
||||
$consumptionPrice = $product['consumption_price'];
|
||||
$total_refund_price = bcsub($product['pay_price'], bcsub($productRefundPrice['refund_price'] ?? 0, $productRefundPrice['refund_postage'] ?? 0, 2), 2);
|
||||
$storeConsumptionUserDao = new StoreConsumptionUserDao();
|
||||
$storeConsumptionUserDao->orderTotalPrice = $order['total_price'];
|
||||
$storeConsumptionUserDao->orderPayPrice = $order['pay_price'];
|
||||
$storeConsumptionUserDao->orderProductPrice = $product['product_price'];
|
||||
[$realPrice, $realPriceTotal, $consumptionPrice] = $storeConsumptionUserDao->calculate();
|
||||
$total_refund_price = bcsub($realPrice, bcsub($productRefundPrice['refund_price'] ?? 0, $productRefundPrice['refund_postage'] ?? 0, 2), 2);
|
||||
$postage_price = (!$order->status || $order->status == 9) ? bcsub($product['postage_price'], $productRefundPrice['refund_postage'] ?? 0, 2) : 0;
|
||||
|
||||
return compact('total_refund_price', 'postage_price', 'consumptionPrice');
|
||||
@ -330,10 +340,18 @@ class StoreRefundOrderRepository extends BaseRepository
|
||||
$total_extension_two = bcadd($total_extension_two, bcmul($product['refund_num'], $product['extension_two'], 2), 2);
|
||||
$postagePrice = (!$order->status || $order->status == 9) ? bcsub($product['postage_price'], $productRefundPrice['refund_postage'] ?? 0, 2) : 0;
|
||||
$totalRefundNum += $product['refund_num'];
|
||||
|
||||
$refundPrice = 0;
|
||||
if ($product['pay_price'] > 0) {
|
||||
$refundPrice = bcsub($product['pay_price'], bcsub($productRefundPrice['refund_price'] ?? 0, $productRefundPrice['refund_postage'] ?? 0, 2), 2);
|
||||
//计算可退金额
|
||||
if ($order['total_price'] > 0) {
|
||||
$isLast = count($products->toArray()) == ($k + 1);
|
||||
$storeConsumptionUserDao = new StoreConsumptionUserDao();
|
||||
$storeConsumptionUserDao->orderTotalPrice = $order['total_price'];
|
||||
$storeConsumptionUserDao->orderPayPrice = $order['pay_price'];
|
||||
$storeConsumptionUserDao->orderProductPrice = $product['product_price'];
|
||||
$storeConsumptionUserDao->realPriceTotal = $totalRefundPrice;
|
||||
$storeConsumptionUserDao->isLast = $isLast;
|
||||
[$refundPrice, $totalRefundPrice, $consumptionPrice] = $storeConsumptionUserDao->calculate();
|
||||
$consumptionTotal = bcadd($consumptionTotal, $consumptionPrice, 2);
|
||||
}
|
||||
|
||||
$platform_refund_price = 0;
|
||||
@ -346,8 +364,6 @@ class StoreRefundOrderRepository extends BaseRepository
|
||||
$integral = bcsub($product['integral_total'], $productRefundPrice['refund_integral'] ?? 0, 0);
|
||||
}
|
||||
|
||||
$consumptionTotal = bcadd($consumptionTotal, $product['consumption_price'], 2);
|
||||
$totalRefundPrice = bcadd($totalRefundPrice, $refundPrice, 2);
|
||||
$totalPostage = bcadd($totalPostage, $postagePrice, 2);
|
||||
$totalPlatformRefundPrice = bcadd($totalPlatformRefundPrice, $platform_refund_price, 2);
|
||||
$totalIntegral = bcadd($totalIntegral, $integral, 2);
|
||||
@ -359,7 +375,7 @@ class StoreRefundOrderRepository extends BaseRepository
|
||||
'platform_refund_price' => $platform_refund_price,
|
||||
'refund_integral' => $integral,
|
||||
'refund_price' => $refundPrice,
|
||||
'refund_consumption' => $product['consumption_price'],
|
||||
'refund_consumption' => $consumptionPrice,
|
||||
'refund_postage' => $postagePrice,
|
||||
];
|
||||
}
|
||||
@ -458,18 +474,12 @@ class StoreRefundOrderRepository extends BaseRepository
|
||||
$postagePrice = (!$order->status || $order->status == 9) ? bcsub($product['postage_price'], $productRefundPrice['refund_postage'] ?? 0, 2) : 0;
|
||||
|
||||
$refundPrice = 0;
|
||||
$consumptionRefund = 0;
|
||||
//计算可退金额
|
||||
if ($product['product_price'] > 0) {
|
||||
// 商品实付单价
|
||||
$payPrice = bcdiv($product['pay_price'], $product['product_num'], 2);
|
||||
$consumptionPrice = bcdiv($product['consumption_price'], $product['product_num'], 2);
|
||||
if ($product['refund_num'] == $num) {
|
||||
$refundPrice = bcsub($product['pay_price'], bcsub($productRefundPrice['refund_price'] ?? 0, $productRefundPrice['refund_postage'] ?? 0, 2), 2);
|
||||
$consumptionRefund = bcsub($product['consumption_price'], $productRefundPrice['refund_consumption'] ?? 0, 2);
|
||||
$refundPrice = bcsub($product['product_price'], bcsub($productRefundPrice['refund_price'] ?? 0, $productRefundPrice['refund_postage'] ?? 0, 2), 2);
|
||||
} else {
|
||||
$refundPrice = bcmul($payPrice, $num, 2);
|
||||
$consumptionRefund = bcmul($consumptionPrice, $num, 2);
|
||||
$refundPrice = bcmul(bcdiv($product['product_price'], $product['product_num'], 2), $num, 2);
|
||||
}
|
||||
}
|
||||
$totalRefundPrice = bcadd($refundPrice, $postagePrice, 2);
|
||||
@ -520,12 +530,11 @@ class StoreRefundOrderRepository extends BaseRepository
|
||||
$data['refund_num'] = $num;
|
||||
$data['extension_one'] = $total_extension_one;
|
||||
$data['extension_two'] = $total_extension_two;
|
||||
$data['refund_consumption'] = $consumptionRefund;
|
||||
if ($order['pay_type'] == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) {
|
||||
$data['refund_price'] = 0;
|
||||
}
|
||||
|
||||
return Db::transaction(function () use ($order, $data, $product, $productId, $num, $consumptionRefund) {
|
||||
return Db::transaction(function () use ($order, $data, $product, $productId, $num) {
|
||||
event('refund.create.before', compact('data'));
|
||||
$refund = $this->dao->create($data);
|
||||
app()->make(StoreRefundProductRepository::class)->create([
|
||||
@ -536,7 +545,6 @@ class StoreRefundOrderRepository extends BaseRepository
|
||||
'refund_price' => $data['refund_price'],
|
||||
'refund_integral' => $data['integral'],
|
||||
'refund_postage' => $data['refund_postage'],
|
||||
'refund_consumption' => $consumptionRefund,
|
||||
]);
|
||||
$product->refund_num -= $num;
|
||||
$product->is_refund = 1;
|
||||
@ -1172,25 +1180,29 @@ class StoreRefundOrderRepository extends BaseRepository
|
||||
//退还赠送积分
|
||||
$this->refundGiveIntegral($refundOrder);
|
||||
|
||||
//退用户使用的红包
|
||||
if ($refundOrder['refund_consumption'] > 0) {
|
||||
(new StoreConsumptionUserDao())->refundByOrder($refundOrder);
|
||||
}
|
||||
|
||||
//活动订单撤销
|
||||
(new StoreActivityOrderDao())->repeal($refundOrder->order->group_order_id);
|
||||
|
||||
//退商户、服务团队的佣金
|
||||
(new CommissionDao())->refundByOrder($refundOrder);
|
||||
|
||||
//退供应链订单
|
||||
(new StoreOrderOtherDao())->refund($refundOrder);
|
||||
|
||||
$productIds = CloudProduct::where('activity_id', 2)->column('product_id');
|
||||
StoreActivityOrderProduct::where('user_id', $refundOrder->order['uid'])
|
||||
->whereIn('product_id', $productIds)
|
||||
->whereIn('activity_id', 2)
|
||||
->update(['status' => 0]);
|
||||
|
||||
app()->make(FinancialRecordRepository::class)->dec([
|
||||
'order_id' => $refundOrder->refund_order_id,
|
||||
'order_sn' => $refundOrder->refund_order_sn,
|
||||
'user_info' => $refundOrder->user->nickname,
|
||||
'user_id' => $refundOrder->uid,
|
||||
'financial_type' => 'refund_order',
|
||||
'type' => 1,
|
||||
'number' => $refundOrder->refund_price,
|
||||
], $refundOrder->mer_id);
|
||||
}
|
||||
|
||||
public function getRefundMerPrice(StoreRefundOrder $refundOrder, $refundPrice = null)
|
||||
@ -1318,6 +1330,8 @@ class StoreRefundOrderRepository extends BaseRepository
|
||||
$_refundRate = bcmul($commission_rate, bcsub($item['data']['refund_price'], $extension, 2), 2);
|
||||
$refundRate = bcadd($refundRate, $_refundRate, 2);
|
||||
}
|
||||
$margin = FinancialRecord::getInstance()->where('mer_id', $res->mer_id)->where('order_sn', $item['sn'])->where('financial_type', 'auto_margin')->value('number');
|
||||
$refundPrice = bcsub($refundPrice, $margin, 2);
|
||||
$refundPriceAll = bcadd($refundPriceAll, $refundPrice, 2);
|
||||
|
||||
try {
|
||||
@ -1348,16 +1362,27 @@ class StoreRefundOrderRepository extends BaseRepository
|
||||
}
|
||||
}
|
||||
|
||||
$financeDao = new FinancialDao();
|
||||
$financeDao->order = $res->order->toArray();
|
||||
$financeDao->order['order_id'] = $res->refund_order_id;
|
||||
$financeDao->order['order_sn'] = $res->refund_order_sn;
|
||||
$financeDao->user = $res->user;
|
||||
$financeDao->platformOut($refundPriceAll, 'order_refund');
|
||||
$financeDao->save();
|
||||
app()->make(FinancialRecordRepository::class)->inc([
|
||||
'order_id' => $res->refund_order_id,
|
||||
'order_sn' => $res->refund_order_sn,
|
||||
'user_info' => $res->user->nickname,
|
||||
'user_id' => $res->uid,
|
||||
'financial_type' => 'refund_true',
|
||||
'number' => $refundPriceAll,
|
||||
'type' => 1,
|
||||
], $res->mer_id);
|
||||
|
||||
// 业务流程调整,暂时注释
|
||||
// event('refund.after', compact('id', 'res'));
|
||||
app()->make(FinancialRecordRepository::class)->inc([
|
||||
'order_id' => $res->refund_order_id,
|
||||
'order_sn' => $res->refund_order_sn,
|
||||
'user_info' => $res->user->nickname,
|
||||
'user_id' => $res->uid,
|
||||
'type' => 1,
|
||||
'financial_type' => 'refund_charge',
|
||||
'number' => $refundRate,
|
||||
], $res->mer_id);
|
||||
|
||||
event('refund.after', compact('id', 'res'));
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ class ParameterValueRepository extends BaseRepository
|
||||
public function create($id, $data,$merId)
|
||||
{
|
||||
if (empty($data)) return ;
|
||||
$create=[];
|
||||
foreach ($data as $datum) {
|
||||
if ($datum['name'] && $datum['value']) {
|
||||
$create[] = [
|
||||
@ -49,7 +48,7 @@ class ParameterValueRepository extends BaseRepository
|
||||
];
|
||||
}
|
||||
}
|
||||
if (count($create)>0) $this->dao->insertAll($create);
|
||||
if ($create) $this->dao->insertAll($create);
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,7 +57,6 @@ class ProductLabelRepository extends BaseRepository
|
||||
$form = Elm::createForm(is_null($id) ? Route::buildUrl($route)->build() : Route::buildUrl($route, ['id' => $id])->build());
|
||||
$form->setRule([
|
||||
Elm::input('label_name', '标签名称')->required(),
|
||||
Elm::input('value', '标签值'),
|
||||
Elm::input('info', '说明'),
|
||||
Elm::number('sort', '排序', 0)->precision(0)->max(99999),
|
||||
Elm::switches('status', '是否显示', 1)->activeValue(1)->inactiveValue(0)->inactiveText('关')->activeText('开'),
|
||||
|
@ -223,9 +223,6 @@ class ProductPresellRepository extends BaseRepository
|
||||
]);
|
||||
$count = $query->count();
|
||||
$list = $query->page($page, $limit)->select()->append(['coupon', 'tattend_one', 'tattend_two', 'seles']);
|
||||
foreach ($list as &$item) {
|
||||
$item['type'] = 0;
|
||||
}
|
||||
return compact('count', 'list');
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ class ProductRepository extends BaseRepository
|
||||
['svip_price_type', 0],
|
||||
['params', []],
|
||||
];
|
||||
protected $admin_filed = 'Product.product_id,Product.mer_id,brand_id,spec_type,unit_name,mer_status,rate,reply_count,store_info,cate_id,Product.image,slider_image,Product.store_name,Product.keyword,Product.sort,U.rank,Product.is_show,Product.sales,Product.price,extension_type,refusal,cost,ot_price,stock,is_gift_bag,Product.care_count,Product.status,is_used,Product.create_time,Product.product_type,old_product_id,star,ficti,integral_total,integral_price_total,sys_labels,param_temp_id,mer_svip_status,svip_price,svip_price_type,Product.update_time,source_product_id';
|
||||
protected $admin_filed = 'Product.product_id,Product.mer_id,brand_id,spec_type,unit_name,mer_status,rate,reply_count,store_info,cate_id,Product.image,slider_image,Product.store_name,Product.keyword,Product.sort,U.rank,Product.is_show,Product.sales,Product.price,extension_type,refusal,cost,ot_price,stock,is_gift_bag,Product.care_count,Product.status,is_used,Product.create_time,Product.product_type,old_product_id,star,ficti,integral_total,integral_price_total,sys_labels,param_temp_id,mer_svip_status,svip_price,svip_price_type,update_time,source_product_id';
|
||||
protected $filed = 'Product.bar_code,Product.product_id,Product.mer_id,brand_id,unit_name,spec_type,mer_status,rate,reply_count,store_info,cate_id,Product.image,slider_image,Product.store_name,Product.keyword,Product.sort,Product.is_show,Product.sales,Product.price,extension_type,refusal,cost,ot_price,stock,is_gift_bag,Product.care_count,Product.status,is_used,Product.create_time,Product.product_type,old_product_id,integral_total,integral_price_total,mer_labels,Product.is_good,Product.is_del,type,param_temp_id,mer_svip_status,svip_price,svip_price_type,update_time,source_product_id';
|
||||
|
||||
const NOTIC_MSG = [
|
||||
@ -115,10 +115,6 @@ class ProductRepository extends BaseRepository
|
||||
'msg' => '被下架'
|
||||
],
|
||||
];
|
||||
|
||||
/** @var bool $force 忽略商品状态 */
|
||||
public $force = false;
|
||||
|
||||
/**
|
||||
* ProductRepository constructor.
|
||||
* @param dao $dao
|
||||
@ -417,8 +413,6 @@ class ProductRepository extends BaseRepository
|
||||
$data['cost'] = $settleParams['data']['cost'];
|
||||
$data['stock'] = $settleParams['data']['stock'];
|
||||
$data['svip_price'] = $settleParams['data']['svip_price'];
|
||||
|
||||
$data['update_time'] = date('Y-m-d H:i:s',time());
|
||||
}
|
||||
$res = $this->dao->update($id, $data);
|
||||
|
||||
@ -1018,83 +1012,6 @@ class ProductRepository extends BaseRepository
|
||||
return compact('count', 'list');
|
||||
}
|
||||
|
||||
|
||||
public function getGoodsList(?int $merId, array $where, int $page, int $limit)
|
||||
{
|
||||
$query = $this->dao->search($merId, $where)->with([
|
||||
'merCateId.category',//商户分类
|
||||
'storeCategory',//平台分类
|
||||
'brand',//商品分类
|
||||
'merchant',
|
||||
'attrValue'
|
||||
]);
|
||||
$count = $query->count();
|
||||
$data = $query->page($page, $limit)->setOption('field', [])->field($this->admin_filed)->select();
|
||||
$data->append(['us_status']);
|
||||
$list = hasMany(
|
||||
$data,
|
||||
'sys_labels',
|
||||
ProductLabel::class,
|
||||
'product_label_id',
|
||||
'sys_labels',
|
||||
['status' => 1],
|
||||
'product_label_id,product_label_id id,label_name name'
|
||||
);
|
||||
|
||||
|
||||
$export = [];
|
||||
foreach ($list as $item) {
|
||||
if($where['type'] == 7 || $where['type'] == 6 ){
|
||||
$mer_status = '平台关闭';
|
||||
}elseif ($where['type'] == 2){
|
||||
if(empty($item['is_used'])){
|
||||
$mer_status = '平台关闭';
|
||||
}else{
|
||||
$mer_status = '下架';
|
||||
}
|
||||
}else{
|
||||
if(empty($item['is_used'])){
|
||||
$mer_status = '平台关闭';
|
||||
}else{
|
||||
$mer_status = '上架显示'; //商品状态 1上架显示 0平台关闭
|
||||
}
|
||||
}
|
||||
if(isset($item['merchant'])&& !empty($item['merchant'])){
|
||||
$is_trader = $item['merchant']['is_trader']?'自营':'非自营';
|
||||
$mer_name = $item['merchant']['mer_name']??'';
|
||||
}else{
|
||||
$is_trader ='';
|
||||
$mer_name = '';
|
||||
}
|
||||
$export[] = [
|
||||
$item['product_id'],
|
||||
$item['store_name'],
|
||||
$mer_name,
|
||||
$is_trader,
|
||||
$item['price'],
|
||||
$item['attrValue'][0]['procure_price'],
|
||||
$item['sales'],//销量
|
||||
$item['stock'],//库存
|
||||
$item['star'],//级别
|
||||
$item['sort'],//排序
|
||||
$mer_status,
|
||||
isset($item['sys_labels'])?$item['sys_labels'][0]['name']:'',//标签
|
||||
$item['is_used'] ? '显示' : '隐藏',//显示
|
||||
$item['update_time'],//更新时间
|
||||
$item['create_time'],//创建时间
|
||||
];
|
||||
}
|
||||
$header = ['商品ID','商品名称','商户名称', '商户类别', '商品售价',
|
||||
'批发价','销量','库存','推荐级别','排序', '商品状态','标签','是否显示', '创建时间', '更新时间',
|
||||
];
|
||||
$filename = '商品列表_' . date('YmdHis');
|
||||
$title = ['商品列表_', '导出时间:' . date('Y-m-d H:i:s', time())];
|
||||
$foot = '';
|
||||
return compact('count', 'header', 'title', 'export', 'foot', 'filename');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* TODO 平台商品列表
|
||||
* @Author:Qinii
|
||||
@ -1289,9 +1206,6 @@ class ProductRepository extends BaseRepository
|
||||
'mer_status' => 1,
|
||||
'product_id' => $id
|
||||
];
|
||||
if ($this->force === true) {
|
||||
unset($where['is_show']);
|
||||
}
|
||||
return $this->apiProductDetail($where, $product_type, null, $userInfo);
|
||||
}
|
||||
|
||||
@ -1372,9 +1286,9 @@ class ProductRepository extends BaseRepository
|
||||
$attr = $this->detailAttr($res['attr']);
|
||||
$attrValue = (in_array($res['product_type'], [3, 4])) ? $res['oldAttrValue'] : $res['attrValue'];
|
||||
$oldProduct = Product::where('product_id', $res['old_product_id'])->field('product_id,stock')->find();
|
||||
$storeActivityId = CloudProduct::where('product_id', $res['product_id'])->value('activity_id');
|
||||
$activityId = CloudProduct::where('product_id', $res['product_id'])->value('activity_id');
|
||||
$sku = $this->detailAttrValue($attrValue, $userInfo, $productType, $activityId);
|
||||
if ($storeActivityId == 2 && isset($oldProduct['stock'])) {
|
||||
if ($activityId == 2 && isset($oldProduct['stock'])) {
|
||||
$res['stock'] = $oldProduct['stock'];
|
||||
foreach ($sku as &$skuItem) {
|
||||
$skuItem['stock'] = $oldProduct['stock'];
|
||||
@ -2041,9 +1955,6 @@ class ProductRepository extends BaseRepository
|
||||
{
|
||||
$cart = null;
|
||||
$where = $this->dao->productShow();
|
||||
if ($data['source'] == 999) {
|
||||
unset($where['is_show']);
|
||||
}
|
||||
$where['product_id'] = $data['product_id'];
|
||||
$where['product_type'] = $data['product_type'];
|
||||
unset($where['is_gift_bag']);
|
||||
|
@ -12,7 +12,6 @@ namespace app\common\repositories\store\product;
|
||||
|
||||
use app\common\model\store\product\CloudProduct;
|
||||
use app\common\model\store\product\Product;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\repositories\store\coupon\StoreCouponProductRepository;
|
||||
use app\common\repositories\store\coupon\StoreCouponRepository;
|
||||
use app\common\repositories\store\StoreActivityRepository;
|
||||
@ -155,26 +154,6 @@ class SpuRepository extends BaseRepository
|
||||
if (!empty($this->orderField)) {
|
||||
$this->dao->orderField = $this->orderField;
|
||||
}
|
||||
//取消数量排序
|
||||
$where['order_remark'] = "none";
|
||||
$queryCount = $this->dao->search($where);
|
||||
// $queryCount->with([
|
||||
// 'merchant' => function ($queryCount) {
|
||||
// $queryCount->field($this->merchantFiled)->with(['type_names', 'street_names']);
|
||||
// },
|
||||
// 'issetCoupon',
|
||||
// 'product.attrValue',
|
||||
// ]);
|
||||
unset($where['order_remark']);
|
||||
$count = $queryCount->count();
|
||||
|
||||
if (isset($where['mer_id'])) {
|
||||
$typeId = Merchant::where('mer_id', $where['mer_id'])->value('type_id');
|
||||
$isOfficialStore = $typeId == 22;
|
||||
}
|
||||
if (isset($isOfficialStore) && $isOfficialStore) {
|
||||
$where['order'] = 'price_asc';
|
||||
}
|
||||
$query = $this->dao->search($where);
|
||||
|
||||
$query->with([
|
||||
@ -185,7 +164,8 @@ class SpuRepository extends BaseRepository
|
||||
'product.attrValue',
|
||||
]);
|
||||
$productMake = app()->make(ProductRepository::class);
|
||||
// $count = $query->count();
|
||||
$count = $query->fetchSql(false)->count();
|
||||
|
||||
if ($limit == 0) {
|
||||
$list = $query->setOption('field', [])->field($this->productFiled)->select()
|
||||
->each(function ($item) use ($is_sku, $productMake, $userInfo,$where) {
|
||||
@ -199,7 +179,7 @@ class SpuRepository extends BaseRepository
|
||||
$item['merchant']['village_name']=$village_name.'集体经营合作店铺';
|
||||
}
|
||||
}
|
||||
if (isset($item['merchant']['lat'] , $item['merchant']['long']) && isset($where['lat'], $where['long'])&&$where['lat']!='') {
|
||||
if (isset($item['merchant']['lat'] , $item['merchant']['long']) && isset($where['lat'], $where['long'])) {
|
||||
$distance = getDistance($where['lat'], $where['long'], $item['merchant']['lat'], $item['merchant']['long']);
|
||||
if ($distance < 0.9) {
|
||||
$distance = max(bcmul($distance, 1000, 0), 1).'m';
|
||||
@ -225,7 +205,7 @@ class SpuRepository extends BaseRepository
|
||||
$item['merchant']['village_name']=$village_name.'集体经营合作店铺';
|
||||
}
|
||||
}
|
||||
if (isset($item['merchant']['lat'] , $item['merchant']['long']) && isset($where['lat'], $where['long'])&&$where['lat']!='') {
|
||||
if (isset($item['merchant']['lat'] , $item['merchant']['long']) && isset($where['lat'], $where['long'])) {
|
||||
$distance = getDistance($where['lat'], $where['long'], $item['merchant']['lat'], $item['merchant']['long']);
|
||||
if ($distance < 0.9) {
|
||||
$distance = max(bcmul($distance, 1000, 0), 1).'m';
|
||||
@ -603,7 +583,6 @@ class SpuRepository extends BaseRepository
|
||||
];
|
||||
break;
|
||||
case 2:
|
||||
/** @var ProductPresellRepository $_make */
|
||||
$_make = app()->make(ProductPresellRepository::class);
|
||||
$res = $_make->getWhere([$_make->getPk() => $id]);
|
||||
$where = [
|
||||
|
@ -88,7 +88,7 @@ class CacheRepository extends BaseRepository
|
||||
['label' => '隐私政策', 'key' => self::USER_PRIVACY],
|
||||
['label' => '平台规则', 'key' => self::PLATFORM_RULE],
|
||||
['label' => '注销重要提示', 'key' => self::CANCELLATION_PROMPT],
|
||||
['label' => '数字供销综合云平台入驻要求和店铺命名规范', 'key' => self::INTEGRAL_AGREE],
|
||||
['label' => '商户入驻申请协议', 'key' => self::INTEGRAL_AGREE],
|
||||
['label' => '交易申请协议', 'key' => self::BUSINESS_APPLY_AGREE],
|
||||
['label' => '商户服务协议', 'key' => self::MERC_SERVICE_AGREE],
|
||||
['label' => '供应链商户补充协议','key' => self::MERC_SUPPLY_AGREE],
|
||||
|
@ -115,7 +115,7 @@ class FinancialRepository extends BaseRepository
|
||||
// ];
|
||||
// break;
|
||||
}
|
||||
return app()->make(MerchantRepository::class)->update($merId,[$key => json_encode($update, JSON_UNESCAPED_UNICODE),'financial_type' => $data['financial_type']]);
|
||||
return app()->make(MerchantRepository::class)->update($merId,[$key => json_encode($update),'financial_type' => $data['financial_type']]);
|
||||
}
|
||||
|
||||
public function applyForm(int $merId)
|
||||
|
@ -16,7 +16,9 @@ namespace app\common\repositories\system\merchant;
|
||||
|
||||
use app\common\dao\system\merchant\FinancialRecordDao;
|
||||
use app\common\repositories\BaseRepository;
|
||||
use app\common\repositories\store\order\StoreOrderRepository;
|
||||
use app\common\repositories\user\UserBillRepository;
|
||||
use app\common\repositories\user\UserRechargeRepository;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Db;
|
||||
|
||||
@ -29,65 +31,6 @@ use think\facade\Db;
|
||||
*/
|
||||
class FinancialRecordRepository extends BaseRepository
|
||||
{
|
||||
|
||||
public $commonFinancialType = [
|
||||
'order', 'order_presell', 'order_refund', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon',
|
||||
'order_svip_coupon','commission_to_service_team','commission_to_service_team_refund','commission_to_platform','commission_to_platform_refund','commission_to_village','commission_to_village_refund','commission_to_town','commission_to_town_refund'
|
||||
,'commission_to_entry_merchant','commission_to_entry_merchant_refund'
|
||||
,'commission_to_cloud_warehouse','commission_to_cloud_warehouse_refund', 'commission_to_store', 'commission_to_courier', 'commission_to_promoter', 'commission_to_store_refund', 'commission_to_courier_refund', 'commission_to_promoter_refund', 'auto_margin', 'auto_margin_refund', 'supply_chain', 'supply_chain_refund', 'platform_consumption', 'platform_consumption_refund', 'merchant_order', 'merchant_order_refund'
|
||||
];
|
||||
|
||||
public $commonFinancialMixType = [
|
||||
'order', 'order_presell', 'order_refund', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon',
|
||||
'order_svip_coupon','commission_to_service_team','commission_to_service_team_refund','commission_to_platform','commission_to_platform_refund','commission_to_village','commission_to_village_refund','commission_to_town','commission_to_town_refund'
|
||||
,'commission_to_entry_merchant','commission_to_entry_merchant_refund'
|
||||
,'commission_to_cloud_warehouse','commission_to_cloud_warehouse_refund', 'commission_to_courier', 'commission_to_store_refund', 'commission_to_courier_refund', 'commission_to_promoter_refund', 'auto_margin','supply_chain', 'supply_chain_refund', 'platform_consumption', 'platform_consumption_refund', 'merchant_order', 'merchant_order_refund'
|
||||
];
|
||||
|
||||
const TYPE_CN_MAP = [
|
||||
'order' => '订单支付',
|
||||
'order_presell' => '预售订单(定金)',
|
||||
'order_refund' => '订单退款',
|
||||
'brokerage_one' => '一级分销佣金',
|
||||
'brokerage_two' => '二级分销佣金',
|
||||
'refund_brokerage_one' => '返还一级佣金',
|
||||
'refund_brokerage_two' => '返还二级佣金',
|
||||
'refund_order' => '订单退款',
|
||||
'order_platform_coupon' => '平台优惠券抵扣',
|
||||
'order_svip_coupon' => '超级会员优惠券抵扣',
|
||||
'commission_to_service_team' => '服务队佣金',
|
||||
'commission_to_platform' => '平台手续费',
|
||||
'commission_to_platform_refund' => '平台手续费退款',
|
||||
'platform_consumption' => '平台优惠',
|
||||
'platform_consumption_refund' => '平台优惠退款',
|
||||
'commission_to_promoter' => '推广人佣金',
|
||||
'commission_to_promoter_refund' => '推广人佣金退款',
|
||||
'auto_margin' => '商户保证金',
|
||||
'auto_margin_refund' => '商户保证金退款',
|
||||
'merchant_order' => '商户订单',
|
||||
'merchant_order_refund' => '商户订单退款',
|
||||
'supply_chain' => '供应链',
|
||||
'presell' => '预售订单(尾款)',
|
||||
'order_charge' => '手续费',
|
||||
'order_true' => '商户入账',
|
||||
'refund_charge' => '返还手续费',
|
||||
'refund_true' => '商户返还入账',
|
||||
'presell_charge' => '预售订单(手续费)',
|
||||
'presell_true' => '商户入账',
|
||||
'mer_presell' => '预售订单(总额)',
|
||||
'refund_platform_coupon' => '退回优惠券补贴',
|
||||
'commission_to_village' => '订单平台佣金',
|
||||
'commission_to_town' => '订单平台佣金',
|
||||
'commission_to_service_team_refund' => '退回平台佣金',
|
||||
'commission_to_village_refund' => '退回平台佣金',
|
||||
'commission_to_town_refund' => '退回平台佣金',
|
||||
'commission_to_entry_merchant' => '订单平台佣金',//入口店铺佣金
|
||||
'commission_to_cloud_warehouse' => '订单平台佣金',//云仓佣金
|
||||
'commission_to_entry_merchant_refund' => '退回平台佣金',
|
||||
'commission_to_cloud_warehouse_refund' => '退回平台佣金',
|
||||
'first_order_commission' => '首单拉新',
|
||||
];
|
||||
|
||||
public function __construct(FinancialRecordDao $dao)
|
||||
{
|
||||
$this->dao = $dao;
|
||||
@ -107,12 +50,6 @@ class FinancialRecordRepository extends BaseRepository
|
||||
$query = $this->dao->search($where)->order('create_time DESC');
|
||||
$count = $query->count();
|
||||
$list = $query->page($page, $limit)->select();
|
||||
foreach ($list as &$item) {
|
||||
if (!empty($where['mer_id'])) {
|
||||
$item['financial_pm'] = $item['financial_pm'] == 0 ? 1 : 0;
|
||||
}
|
||||
$item['financial_type_cn'] = $this->getFinancialTypeCn($item['financial_type']);
|
||||
}
|
||||
return compact('count', 'list');
|
||||
}
|
||||
|
||||
@ -178,45 +115,33 @@ class FinancialRecordRepository extends BaseRepository
|
||||
//订单收入总金额
|
||||
$count = $this->dao->search($where)->where('financial_type', 'in', ['order', 'order_presell', 'presell'])->sum('number');
|
||||
//退款支出金额
|
||||
$refund_order = $this->dao->search($where)->where('financial_type', 'order_refund')->sum('number');
|
||||
$platformProfit = bcsub($count, $refund_order, 2);
|
||||
//供应链金额
|
||||
$supply = $this->dao->search($where)->where('financial_type', 'supply_chain')->sum('number');
|
||||
$supplyRefund = $this->dao->search($where)->where('financial_type', 'supply_chain_refund')->sum('number');
|
||||
$platformProfit = bcsub($platformProfit, $supply, 2);
|
||||
$platformProfit = bcadd($platformProfit, $supplyRefund, 2);
|
||||
$refund_order = $this->dao->search($where)->where('financial_type', 'refund_order')->sum('number');
|
||||
//佣金支出金额
|
||||
$brokerage_ = $this->dao->search($where)->where('financial_type', 'in', ['brokerage_one', 'brokerage_two'])->sum('number');
|
||||
$_brokerage = $this->dao->search($where)->where('financial_type', 'in', ['refund_brokerage_two', 'refund_brokerage_one'])->sum('number');
|
||||
$brokerage = bcsub($brokerage_, $_brokerage, 2);
|
||||
$platformProfit = bcsub($platformProfit, $brokerage, 2);
|
||||
// 保证金
|
||||
$margin = $this->dao->search($where)->where('financial_type', 'auto_margin')->sum('number');
|
||||
$marginRefund = $this->dao->search($where)->where('financial_type', 'auto_margin_refund')->sum('number');
|
||||
$platformProfit = bcadd($platformProfit, $margin, 2);
|
||||
$platformProfit = bcsub($platformProfit, $marginRefund, 2);
|
||||
//直推首单佣金
|
||||
$promoter = $this->dao->search($where)->where('financial_type', 'commission_to_promoter')->sum('number');
|
||||
$promoterRefund = $this->dao->search($where)->where('financial_type', 'commission_to_promoter_refund')->sum('number');
|
||||
$platformProfit = bcsub($platformProfit, $promoter, 2);
|
||||
$platformProfit = bcadd($platformProfit, $promoterRefund, 2);
|
||||
//配送员佣金
|
||||
$courier = $this->dao->search($where)->where('financial_type', 'commission_to_courier')->sum('number');
|
||||
$courierRefund = $this->dao->search($where)->where('financial_type', 'commission_to_courier_refund')->sum('number');
|
||||
$platformProfit = bcsub($platformProfit, $courier, 2);
|
||||
$platformProfit = bcadd($platformProfit, $courierRefund, 2);
|
||||
//提货店铺佣金
|
||||
$store = $this->dao->search($where)->where('financial_type', 'commission_to_store')->sum('number');
|
||||
$storeRefund = $this->dao->search($where)->where('financial_type', 'commission_to_store_refund')->sum('number');
|
||||
$platformProfit = bcsub($platformProfit, $store, 2);
|
||||
$platformProfit = bcadd($platformProfit, $storeRefund, 2);
|
||||
|
||||
//入口店铺佣金
|
||||
$entry_merchant=$this->dao->search($where)->where('financial_type', 'commission_to_entry_merchant')->sum('number');
|
||||
$entry_merchant_refund=$this->dao->search($where)->where('financial_type', 'commission_to_entry_merchant_refund')->sum('number');
|
||||
//云仓库佣金
|
||||
$cloud_warehouse=$this->dao->search($where)->where('financial_type', 'commission_to_cloud_warehouse')->sum('number');
|
||||
$cloud_warehouse_refund=$this->dao->search($where)->where('financial_type', 'commission_to_cloud_warehouse_refund')->sum('number');
|
||||
//服务团队佣金
|
||||
$service_team=$this->dao->search($where)->where('financial_type', 'commission_to_service_team')->sum('number');
|
||||
$service_team_refund=$this->dao->search($where)->where('financial_type', 'commission_to_service_team_refund')->sum('number');
|
||||
//村团队佣金
|
||||
$village=$this->dao->search($where)->where('financial_type', 'commission_to_village')->sum('number');
|
||||
$village_refund=$this->dao->search($where)->where('financial_type', 'commission_to_village_refund')->sum('number');
|
||||
//镇佣金
|
||||
$town=$this->dao->search($where)->where('financial_type', 'commission_to_town')->sum('number');
|
||||
$town_refund=$this->dao->search($where)->where('financial_type', 'commission_to_town_refund')->sum('number');
|
||||
//平台手续费
|
||||
$charge_ = $this->dao->search($where)->where('financial_type', 'in', ['order_charge', 'presell_charge'])->sum('number');
|
||||
$_charge = $this->dao->search($where)->where('financial_type', 'refund_charge')->sum('number');
|
||||
$charge = bcsub($charge_, $_charge, 2);
|
||||
//优惠券费用 ,'order_platform_coupon','order_svip_coupon'
|
||||
$coupon = $this->dao->search($where)->where('financial_type', 'in', ['order_platform_coupon', 'order_svip_coupon'])->sum('number');
|
||||
// 消费金
|
||||
$consumption = $this->dao->search($where)->where('financial_type', 'platform_consumption')->sum('number');
|
||||
$consumptionRefund = $this->dao->search($where)->where('financial_type', 'platform_consumption_refund')->sum('number');
|
||||
$platformProfit = bcsub($platformProfit, $consumption, 2);
|
||||
$platformProfit = bcadd($platformProfit, $consumptionRefund, 2);
|
||||
//充值金额
|
||||
$bill_where = [
|
||||
'status' => 1,
|
||||
@ -248,24 +173,18 @@ class FinancialRecordRepository extends BaseRepository
|
||||
'field' => '元',
|
||||
'name' => '退款支出金额'
|
||||
],
|
||||
[
|
||||
'className' => 'el-icon-s-goods',
|
||||
'count' => $supply,
|
||||
'field' => '元',
|
||||
'name' => '供应链成本'
|
||||
],
|
||||
[
|
||||
'className' => 'el-icon-s-order',
|
||||
'count' => $supplyRefund,
|
||||
'field' => '元',
|
||||
'name' => '供应链退款'
|
||||
],
|
||||
[
|
||||
'className' => 'el-icon-s-cooperation',
|
||||
'count' => $brokerage,
|
||||
'field' => '元',
|
||||
'name' => '佣金支出金额'
|
||||
],
|
||||
[
|
||||
'className' => 'el-icon-s-cooperation',
|
||||
'count' => $charge,
|
||||
'field' => '元',
|
||||
'name' => '平台手续费'
|
||||
],
|
||||
[
|
||||
'className' => 'el-icon-s-finance',
|
||||
'count' => $bill,
|
||||
@ -289,42 +208,36 @@ class FinancialRecordRepository extends BaseRepository
|
||||
'count' => $coupon,
|
||||
'field' => '元',
|
||||
'name' => '优惠券金额'
|
||||
],
|
||||
[
|
||||
],[
|
||||
'className' => 'el-icon-s-order',
|
||||
'count' => bcsub($margin, $marginRefund, 2),
|
||||
'count' => bcsub($entry_merchant,$entry_merchant_refund,2),
|
||||
'field' => '元',
|
||||
'name' => '店铺保证金'
|
||||
],
|
||||
[
|
||||
'name' => '入口商户佣金'
|
||||
],[
|
||||
'className' => 'el-icon-s-order',
|
||||
'count' => bcsub($promoter, $promoterRefund, 2),
|
||||
'count' => bcsub($cloud_warehouse,$cloud_warehouse_refund,2),
|
||||
'field' => '元',
|
||||
'name' => '直推首单佣金'
|
||||
],
|
||||
[
|
||||
'name' => '云仓库佣金'
|
||||
],[
|
||||
'className' => 'el-icon-s-order',
|
||||
'count' => bcsub($courier, $courierRefund, 2),
|
||||
'count' => bcsub($service_team,$service_team_refund,2),
|
||||
'field' => '元',
|
||||
'name' => '配送员佣金'
|
||||
],
|
||||
[
|
||||
'name' => '小组服务佣金'
|
||||
],[
|
||||
'className' => 'el-icon-s-order',
|
||||
'count' => bcsub($store, $storeRefund, 2),
|
||||
'count' => bcsub($village,$village_refund,2),
|
||||
'field' => '元',
|
||||
'name' => '提货店铺佣金'
|
||||
],
|
||||
[
|
||||
'name' => '村佣金'
|
||||
],[
|
||||
'className' => 'el-icon-s-order',
|
||||
'count' => bcsub($consumption, $consumptionRefund, 2),
|
||||
'count' => bcsub($town,$town_refund,2),
|
||||
'field' => '元',
|
||||
'name' => '平台红包(包含通用和抵扣)'
|
||||
],
|
||||
[
|
||||
'name' => '镇佣金'
|
||||
],[
|
||||
'className' => 'el-icon-s-order',
|
||||
'count' => $platformProfit,
|
||||
'count' =>bcsub($charge, bcadd(bcadd(bcadd($entry_merchant, $cloud_warehouse, 2), $service_team, 2), $village, 2), 2),
|
||||
'field' => '元',
|
||||
'name' => '平台结余'
|
||||
'name' => '平台剩余手续费'
|
||||
],
|
||||
];
|
||||
return compact('stat');
|
||||
@ -340,7 +253,7 @@ class FinancialRecordRepository extends BaseRepository
|
||||
public function getMerchantTitle($where)
|
||||
{
|
||||
//商户收入
|
||||
$count = $this->dao->search($where)->where('financial_type', 'in', ['order', 'mer_presell', 'supply_chain'])->sum('number');
|
||||
$count = $this->dao->search($where)->where('financial_type', 'in', ['order', 'mer_presell'])->sum('number');
|
||||
//押金
|
||||
$auto_margin = $this->dao->search($where)->where('financial_type', 'auto_margin')->sum('number');
|
||||
$auto_margin_refund = $this->dao->search($where)->where('financial_type', 'auto_margin_refund')->sum('number');
|
||||
@ -353,18 +266,22 @@ class FinancialRecordRepository extends BaseRepository
|
||||
//商户可提现金额
|
||||
$_line = bcsub($mer_money, $extract_minimum_line, 2);
|
||||
//退款支出金额
|
||||
$refund_order = $this->dao->search($where)->where('financial_type', 'in', ['refund_order', 'supply_chain_refund'])->sum('number');
|
||||
//平台佣金
|
||||
$commission = $this->dao->search($where)->whereIn('financial_type', ['commission_to_store', 'commission_to_promoter'])->sum('number');
|
||||
$commissionRefund = $this->dao->search($where)->whereIn('financial_type', ['commission_to_store_refund', 'commission_to_promoter_refund'])->sum('number');
|
||||
$commission = bcsub($commission, $commissionRefund, 2);
|
||||
$refund_order = $this->dao->search($where)->where('financial_type', 'refund_order')->sum('number');
|
||||
//佣金支出金额
|
||||
$_brokerage = $this->dao->search($where)->where('financial_type', 'in', ['brokerage_one', 'brokerage_two'])->sum('number');
|
||||
$refund_brokerage = $this->dao->search($where)->where('financial_type', 'in', ['refund_brokerage_one', 'refund_brokerage_two'])->sum('number');
|
||||
$brokerage = bcsub($_brokerage, $refund_brokerage, 2);
|
||||
//平台手续费
|
||||
$refund_true = $this->dao->search($where)->where('financial_type', 'in', ['order_charge', 'presell_charge'])->sum('number');
|
||||
$order_charge = $this->dao->search($where)->where('financial_type', 'refund_charge')->sum('number');
|
||||
$charge = bcsub($refund_true, $order_charge, 2);
|
||||
//商户可提现金额
|
||||
// $bill_order = app()->make(StoreOrderRepository::class)->search(['paid' => 1,'date' => $where['date'],'pay_type' => 0])->sum('pay_price');
|
||||
$merLockMoney = app()->make(UserBillRepository::class)->merchantLickMoney($where['is_mer']);
|
||||
$stat = [
|
||||
[
|
||||
'className' => 'el-icon-s-goods',
|
||||
'count' => bcsub($count, 0, 2),
|
||||
'count' => $count,
|
||||
'field' => '元',
|
||||
'name' => '商户收入'
|
||||
],
|
||||
@ -382,15 +299,27 @@ class FinancialRecordRepository extends BaseRepository
|
||||
],
|
||||
[
|
||||
'className' => 'el-icon-s-cooperation',
|
||||
'count' => bcsub($refund_order, 0, 2),
|
||||
'count' => $refund_order,
|
||||
'field' => '元',
|
||||
'name' => '退款支出'
|
||||
],
|
||||
[
|
||||
'className' => 'el-icon-s-cooperation',
|
||||
'count' => $commission,
|
||||
'className' => 'el-icon-s-finance',
|
||||
'count' => $brokerage,
|
||||
'field' => '元',
|
||||
'name' => '平台佣金'
|
||||
'name' => '佣金支出'
|
||||
],
|
||||
[
|
||||
'className' => 'el-icon-s-cooperation',
|
||||
'count' => $charge,
|
||||
'field' => '元',
|
||||
'name' => '平台手续费'
|
||||
],
|
||||
[
|
||||
'className' => 'el-icon-s-cooperation',
|
||||
'count' => $coupon,
|
||||
'field' => '元',
|
||||
'name' => '平台优惠券补贴'
|
||||
],
|
||||
[
|
||||
'className' => 'el-icon-s-cooperation',
|
||||
@ -421,8 +350,7 @@ class FinancialRecordRepository extends BaseRepository
|
||||
//日
|
||||
if ($where['type'] == 1) {
|
||||
$field = Db::raw('from_unixtime(unix_timestamp(create_time),\'%Y-%m-%d\') as time');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//月
|
||||
if (!empty($where['date'])) {
|
||||
list($startTime, $endTime) = explode('-', $where['date']);
|
||||
@ -433,13 +361,12 @@ class FinancialRecordRepository extends BaseRepository
|
||||
}
|
||||
$field = Db::raw('from_unixtime(unix_timestamp(create_time),\'%Y-%m\') as time');
|
||||
}
|
||||
// $make = app()->make(UserBillRepository::class);
|
||||
$make = app()->make(UserBillRepository::class);
|
||||
|
||||
$query = $this->dao->search($where)->field($field)->group("time")->order('create_time DESC');
|
||||
$count = $query->count();
|
||||
$list = $query->page($page, $limit)->select()->each(function ($item) use ($where, $merchant) {
|
||||
$key = $where['is_mer'] ? $where['is_mer'] . '_financial_record_list_' . $item['time'] : 'sys_financial_record_list_' . $item['time'];
|
||||
|
||||
if (($where['type'] == 1 && ($item['time'] == date('Y-m-d', time()))) || ($where['type'] == 2 && ($item['time'] == date('Y-m', time())))) {
|
||||
$income = ($this->countIncome($where['type'], $where, $item['time'],$merchant))['number'];
|
||||
$expend = ($this->countExpend($where['type'], $where, $item['time'],$merchant))['number'];
|
||||
@ -449,7 +376,7 @@ class FinancialRecordRepository extends BaseRepository
|
||||
'charge' => bcsub($income, $expend, 2),
|
||||
];
|
||||
} else {
|
||||
if (empty(Cache::get($key))) {
|
||||
if (!$ret = Cache::get($key)) {
|
||||
$income = ($this->countIncome($where['type'], $where, $item['time'],$merchant))['number'];
|
||||
$expend = ($this->countExpend($where['type'], $where, $item['time'],$merchant))['number'];
|
||||
$ret = [
|
||||
@ -458,8 +385,6 @@ class FinancialRecordRepository extends BaseRepository
|
||||
'charge' => bcsub($income, $expend, 2),
|
||||
];
|
||||
Cache::tag('system')->set($key, $ret, 24 * 3600);
|
||||
} else{
|
||||
$ret = Cache::get($key);
|
||||
}
|
||||
}
|
||||
$item['income'] = $ret['income'];
|
||||
@ -509,15 +434,11 @@ class FinancialRecordRepository extends BaseRepository
|
||||
'number' => $expend['number'],
|
||||
'count' => $expend['count'] . '笔',
|
||||
'data' => [
|
||||
['订单退款金额', $expend['number_refund'] . '元', $expend['count_refund'] . '笔'],
|
||||
['应付商户金额', $expend['number_supply_chain'] . '元', $expend['count_supply_chain'] . '笔'],
|
||||
['应付商户金额', $expend['number_order'] . '元', $expend['count_order'] . '笔'],
|
||||
['佣金', $expend['number_brokerage'] . '元', $expend['count_brokerage'] . '笔'],
|
||||
['返还手续费', $expend['number_charge'] . '元', $expend['count_charge'] . '笔'],
|
||||
['优惠券补贴', $expend['number_coupon'] . '元', $expend['count_coupon'] . '笔'],
|
||||
['会员优惠券补贴', $expend['number_svipcoupon'] . '元', $expend['count_svipcoupon'] . '笔'],
|
||||
['平台红包补贴', $expend['number_consumption'] . '元', $expend['count_consumption'] . '笔'],
|
||||
['服务团队佣金', $expend['number_commission'] . '元', $expend['count_commission'] . '笔'],
|
||||
['保证金退款', $expend['number_margin'] . '元', $expend['count_margin'] . '笔'],
|
||||
]
|
||||
];
|
||||
$data['charge'] = [
|
||||
@ -549,13 +470,11 @@ class FinancialRecordRepository extends BaseRepository
|
||||
|
||||
$data['date'] = $date;
|
||||
$data['income'] = [
|
||||
'title' => '收入总金额',
|
||||
'title' => '订单收入总金额',
|
||||
'number' => $income['number'],
|
||||
'count' => $income['count'] . '笔',
|
||||
'data' => [
|
||||
['订单支付', $income['number_order'] . '元', $income['count_order'] . '笔'],
|
||||
['平台佣金', $income['number_commission'] . '元', $income['count_commission'] . '笔'],
|
||||
['保证金退还', $income['number_margin_refund'] . '元', $income['count_margin_refund'] . '笔'],
|
||||
['优惠券补贴', $income['number_coupon'] . '元', $income['count_coupon'] . '笔'],
|
||||
['会员优惠券补贴', $income['number_svipcoupon'] . '元', $income['count_svipcoupon'] . '笔'],
|
||||
]
|
||||
@ -565,10 +484,16 @@ class FinancialRecordRepository extends BaseRepository
|
||||
'number' => $expend['number'],
|
||||
'count' => $expend['count'] . '笔',
|
||||
'data' => [
|
||||
[
|
||||
'平台手续费',
|
||||
bcsub($expend['number_order_charge'], $expend['number_charge'], 2). '元',
|
||||
bcsub($expend['count_order_charge'], $expend['count_charge']). '笔',
|
||||
],
|
||||
[
|
||||
'店铺押金',
|
||||
$expend['number_auto_margin'] . '元',
|
||||
$expend['count_auto_margin'] . '笔'
|
||||
|
||||
],
|
||||
[
|
||||
'自动下单市供应链',
|
||||
@ -617,14 +542,9 @@ class FinancialRecordRepository extends BaseRepository
|
||||
*/
|
||||
public function countIncome($type, $where, $date, $merchant = [])
|
||||
{
|
||||
if ($where['is_mer'] > 0) {
|
||||
$financialType = ['supply_chain'];
|
||||
} else {
|
||||
$financialType = ['order', 'commission_to_store_refund', 'commission_to_promoter_refund',
|
||||
'commission_to_courier_refund', 'supply_chain_refund', 'auto_margin', 'platform_consumption_refund'];
|
||||
}
|
||||
$financialType = ['order', 'order_presell', 'presell', 'mer_presell'];
|
||||
if ($merchant){
|
||||
switch ($merchant['type_id']) {//21?
|
||||
switch ($merchant['type_id']) {
|
||||
case 16:
|
||||
$financialType1 = ['commission_to_town'];
|
||||
break;
|
||||
@ -644,9 +564,7 @@ class FinancialRecordRepository extends BaseRepository
|
||||
$financialType1 = [];
|
||||
}
|
||||
|
||||
|
||||
|
||||
$financialType = array_merge($financialType, $financialType1,$this->commonFinancialMixType);
|
||||
$financialType = array_merge($financialType, $financialType1);
|
||||
}
|
||||
[$data['count_order'], $data['number_order']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||
if (!empty($financialType1)){
|
||||
@ -669,13 +587,9 @@ class FinancialRecordRepository extends BaseRepository
|
||||
$financialType = ['refund_svip_coupon'];
|
||||
}
|
||||
[$data['count_svipcoupon'], $data['number_svipcoupon']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||
[$data['count_commission'], $data['number_commission']] = $this->dao->getDataByType($type, $where, $date, ['commission_to_store', 'commission_to_promoter']);
|
||||
[$data['count_margin_refund'], $data['number_margin_refund']] = $this->dao->getDataByType($type, $where, $date, ['auto_margin_refund']);
|
||||
|
||||
$data['count'] = $data['count_order'] + $data['count_commission'] + $data['count_margin_refund'];
|
||||
$data['count'] = $data['count_order'];
|
||||
$data['number'] = bcadd($data['number_coupon'], $data['number_order'], 2);
|
||||
$data['number'] = bcadd($data['number'], $data['number_commission'], 2);
|
||||
$data['number'] = bcadd($data['number'], $data['number_margin_refund'], 2);
|
||||
return $data;
|
||||
}
|
||||
|
||||
@ -758,54 +672,90 @@ class FinancialRecordRepository extends BaseRepository
|
||||
}
|
||||
if ($where['is_mer']) { //商户的
|
||||
//退回收入
|
||||
$financialType = ['supply_chain_refund'];
|
||||
$financialType = ['refund_order'];
|
||||
[$data['count_refund'], $data['number_refund']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||
|
||||
//平台手续费
|
||||
[$data['count_order_charge'], $data['number_order_charge']] = [0, 0];
|
||||
[$data['count_supply_chain'], $data['number_supply_chain']] = [0, 0];
|
||||
$financialType = ['order_charge', 'presell_charge'];
|
||||
[$data['count_order_charge'], $data['number_order_charge']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||
|
||||
//转给市级供应链
|
||||
$financialType = ['supply_chain'];
|
||||
[$data['count_supply_chain'], $data['number_supply_chain']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||
//商户押金
|
||||
$financialType = ['auto_margin'];
|
||||
[$data['count_auto_margin'], $data['number_auto_margin']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||
//商户押金退回
|
||||
$financialType = ['auto_margin_refund'];
|
||||
[$data['count_auto_margin_refund'], $data['number_auto_margin_refund']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||
$number3 = bcsub($data['number_auto_margin'], $data['number_auto_margin_refund'], 2);
|
||||
$data['count_auto_margin'] = bcsub($data['count_auto_margin'], $data['count_auto_margin_refund']);
|
||||
$data['number_auto_margin'] = $number3;
|
||||
//退回佣金
|
||||
[$data['count_refund_brokerage'], $data['number_refund_brokerage']] = [0, 0];
|
||||
//退回给平台的优惠券金额
|
||||
[$data['count_coupon'], $data['number_coupon']] = [0, 0];
|
||||
//退回给平台的会员优惠券金额
|
||||
[$data['count_svipcoupon'], $data['number_svipcoupon']] = [0, 0];
|
||||
if($data['number_supply_chain']>0){
|
||||
[$data['count_commission_to_cloud_warehouse'], $data['number_commission_to_cloud_warehouse']] = [0, 0];
|
||||
}
|
||||
$financialType = ['refund_order', 'supply_chain_refund', 'commission_to_promoter_refund', 'commission_to_store_refund', 'auto_margin'];
|
||||
[$data['count'], $data['number']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||
$data['number'] = bcsub($data['number'], 0, 2);
|
||||
} else { //平台的
|
||||
[$data['count_order'], $data['number_order']] = $this->dao->getDataByType($type, $where, $date, ['order']);
|
||||
// 退款订单
|
||||
[$data['count_refund'], $data['number_refund']] = $this->dao->getDataByType($type, $where, $date, ['order_refund']);
|
||||
$total = $data['number_refund'];
|
||||
// 供应链订单
|
||||
[$data['count_supply_chain'], $data['number_supply_chain']] = $this->dao->getDataByType($type, $where, $date, ['supply_chain']);
|
||||
$total = bcadd($total, $data['number_supply_chain'], 2);
|
||||
// 退保证金记录
|
||||
[$data['count_margin'], $data['number_margin']] = $this->dao->getDataByType($type, $where, $date, ['auto_margin_refund']);
|
||||
$total = bcadd($total, $data['number_margin'], 2);
|
||||
//付给商户的优惠券抵扣金额
|
||||
[$data['count_coupon'], $data['number_coupon']] = $this->dao->getDataByType($type, $where, $date, ['order_platform_coupon']);
|
||||
$total = bcadd($total, $data['number_coupon'], 2);
|
||||
//付给商户的svip优惠券抵扣金额
|
||||
[$data['count_svipcoupon'], $data['number_svipcoupon']] = $this->dao->getDataByType($type, $where, $date, ['order_svip_coupon']);
|
||||
$total = bcadd($total, $data['number_svipcoupon'], 2);
|
||||
//付给服务团队和其他的佣金
|
||||
$financialType = ['commission_to_store', 'commission_to_courier', 'commission_to_promoter'];
|
||||
[$data['count_commission'], $data['number_commission']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||
$total = bcadd($total, $data['number_commission'], 2);
|
||||
//平台红包
|
||||
$financialType = ['platform_consumption'];
|
||||
[$data['count_consumption'], $data['number_consumption']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||
$total = bcadd($total, $data['number_consumption'], 2);
|
||||
$financialType = ['refund_brokerage_two', 'refund_brokerage_one'];
|
||||
[$data['count_refund_brokerage'], $data['number_refund_brokerage']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||
|
||||
$data['count'] = $data['count_refund'] + $data['count_supply_chain'] + $data['count_margin'] + $data['count_coupon'] + $data['count_svipcoupon'] + $data['count_commission'] + $data['count_consumption'];
|
||||
$data['number'] = $total;
|
||||
//退回给平台的优惠券金额
|
||||
$financialType = ['refund_platform_coupon'];
|
||||
[$data['count_coupon'], $data['number_coupon']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||
//退回给平台的会员优惠券金额
|
||||
$financialType = ['refund_svip_coupon'];
|
||||
[$data['count_svipcoupon'], $data['number_svipcoupon']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||
// if (!empty($financialType1)){
|
||||
// $financialType2= [explode('_refund',$financialType1[0])[0]];
|
||||
// halt($financialType1,$financialType2);
|
||||
// [$data['count_commission'], $data['number_commission']] = $this->dao->getDataByType($type, $where, $date, $financialType1);
|
||||
// [$data['count_commission2'], $data['number_commission2']] = $this->dao->getDataByType($type, $where, $date, $financialType2);
|
||||
// $data['count_brokerage']+=$data['count_commission2']-$data['count_commission'];
|
||||
// $data['number_brokerage']+=$data['number_commission2']-$data['number_commission'];
|
||||
// }
|
||||
//佣金 brokerage_one,brokerage_two - 退回佣金 refund_brokerage_two,refund_brokerage_one )
|
||||
$number = bcsub($data['number_brokerage'], $data['number_refund_brokerage'], 2);
|
||||
//平台手续费 =( order_charge + 预售手续费 presell_charge - 平台退给商户的手续费 refund_charge )
|
||||
$number_1 = bcsub($data['number_order_charge'], $data['number_charge'], 2);
|
||||
if($data['number_supply_chain']>0){
|
||||
$financialType = ['commission_to_cloud_warehouse'];
|
||||
[$data['count_commission_to_cloud_warehouse'], $data['number_commission_to_cloud_warehouse']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||
$number_1=bcadd($number_1, $data['number_supply_chain'], 2);
|
||||
$number_1=bcsub( $number_1, $data['number_commission_to_cloud_warehouse'], 2);
|
||||
}
|
||||
|
||||
//退回收入 refund_order + 退回佣金
|
||||
$number_2 = bcadd(bcadd($data['number_refund'], $data['number_coupon'], 2), $data['number_svipcoupon'], 2);
|
||||
$data['count'] =$data['count_supply_chain']+ $data['count_brokerage'] + $data['count_refund'] + $data['count_order_charge'] + $data['count_refund_brokerage'] + $data['count_svipcoupon'] + $data['count_auto_margin']-$data['count_charge'];
|
||||
$data['number'] = bcadd(bcadd($number3,bcadd($number_2, $number, 2),2), $number_1, 2);
|
||||
|
||||
} else { //平台的
|
||||
// 退回 订单实际获得金额
|
||||
|
||||
$financialType = ['order_true', 'presell_true','auto_margin'];
|
||||
[$data['count_order'], $data['number_order']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||
|
||||
$financialType = ['commission_to_entry_merchant'];
|
||||
[$data['count_merchant'], $data['number_merchant']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||
$data['count_order']=bcsub($data['count_order'],$data['count_merchant']);
|
||||
$data['number_order']=bcsub($data['number_order'],$data['number_merchant'], 2);
|
||||
|
||||
//付给商户的优惠券抵扣金额
|
||||
$financialType = ['order_platform_coupon'];
|
||||
[$data['count_coupon'], $data['number_coupon']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||
|
||||
//付给商户的svip优惠券抵扣金额
|
||||
$financialType = ['order_svip_coupon'];
|
||||
[$data['count_svipcoupon'], $data['number_svipcoupon']] = $this->dao->getDataByType($type, $where, $date, $financialType);
|
||||
|
||||
//付给服务团队和其他的佣金
|
||||
[$data['count_refund'], $data['number_refund']] = $this->dao->getDataByType($type, $where, $date, $refund);
|
||||
[$data['count_commission'], $data['number_commission']] = $this->dao->getDataByType($type, $where, $date, $commission);
|
||||
|
||||
$data['count_brokerage']+=$data['count_commission']-$data['count_refund'];
|
||||
$data['number_brokerage']+=$data['number_commission']-$data['number_refund'];
|
||||
|
||||
$number = bcadd($data['number_brokerage'], $data['number_order'], 2);
|
||||
$number_1 = bcadd(bcadd($number, $data['number_coupon'], 2), $data['number_svipcoupon'], 2);
|
||||
|
||||
$data['count'] = $data['count_brokerage'] + $data['count_order'] + $data['count_charge'];
|
||||
$data['number'] = bcadd($number_1, $data['number_charge'], 2);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
@ -841,15 +791,4 @@ class FinancialRecordRepository extends BaseRepository
|
||||
|
||||
return compact('count', 'number');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取财务类型
|
||||
* @param $type
|
||||
* @return string
|
||||
*/
|
||||
public function getFinancialTypeCn($type)
|
||||
{
|
||||
return self::TYPE_CN_MAP[$type] ?? '';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,11 +12,7 @@
|
||||
|
||||
namespace app\common\repositories\system\merchant;
|
||||
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\model\system\merchant\MerchantCategory;
|
||||
use app\common\model\system\merchant\MerchantIntention;
|
||||
use app\common\repositories\BaseRepository;
|
||||
use app\common\repositories\system\config\ConfigValueRepository;
|
||||
use crmeb\jobs\SendSmsJob;
|
||||
use crmeb\services\SmsService;
|
||||
use FormBuilder\Factory\Elm;
|
||||
@ -104,7 +100,6 @@ class MerchantIntentionRepository extends BaseRepository
|
||||
|
||||
public function updateStatus($id, $data)
|
||||
{
|
||||
$data['create_mer'] = !empty($data['create_mer']) ? $data['create_mer'] : 2;
|
||||
$create = ($data['create_mer'] == 1 || $data['create_mer'] == -1);
|
||||
$autoCreate = 0;
|
||||
if ($data['create_mer'] == -1) {
|
||||
@ -119,11 +114,9 @@ class MerchantIntentionRepository extends BaseRepository
|
||||
$config = systemConfig(['broadcast_room_type', 'broadcast_goods_type']);
|
||||
|
||||
$margin = app()->make(MerchantTypeRepository::class)->get($intention['mer_type_id']);
|
||||
$commissionRate = MerchantCategory::where('merchant_category_id', $intention['merchant_category_id'])->value('commission_rate');
|
||||
$data['is_margin'] = $margin['is_margin'] ?? -1;
|
||||
$data['margin'] = $margin['margin'] ?? 0;
|
||||
$merData = [];
|
||||
$smsData = [];
|
||||
if ($create) {
|
||||
$password = substr($intention['phone'], -6);
|
||||
$merData = [
|
||||
@ -149,10 +142,6 @@ class MerchantIntentionRepository extends BaseRepository
|
||||
'reg_admin_id' => 0,
|
||||
'mer_intention_id' => $id,
|
||||
'is_company'=>$intention['is_company'],
|
||||
'business_status'=>2,
|
||||
'mer_settlement_agree_status'=>1,
|
||||
'commission_rate'=>$commissionRate * 100,
|
||||
'financial_bank'=>$intention['financial_bank'],
|
||||
];
|
||||
if($margin['type_code']=='PersonalStore'){
|
||||
$merData['mer_address']='集体地址';
|
||||
@ -161,6 +150,8 @@ class MerchantIntentionRepository extends BaseRepository
|
||||
$merData['mini_banner']='https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/oa_app/23565656.png';
|
||||
$merData['create_time']=date('Y-m-d H:i:s');
|
||||
$merData['update_time']=date('Y-m-d H:i:s',time()+1);
|
||||
$merData['business_status']=2;
|
||||
$merData['mer_settlement_agree_status']=1;
|
||||
}
|
||||
$data['fail_msg'] = '';
|
||||
$smsData = [
|
||||
@ -183,11 +174,6 @@ class MerchantIntentionRepository extends BaseRepository
|
||||
if ($data['status'] == 1) {
|
||||
if ($create) {
|
||||
$merchant = app()->make(MerchantRepository::class)->createMerchant($merData);
|
||||
if (!empty($intention['images'])) {
|
||||
app()->make(ConfigValueRepository::class)->setFormData([
|
||||
'mer_certificate' => $intention['images']
|
||||
], $merchant->mer_id);
|
||||
}
|
||||
$data['mer_id'] = $merchant->mer_id;
|
||||
$data['uid'] = $intention['uid'];
|
||||
$data['reg_admin_id'] = $autoCreate ? 0: $merchant['merchant_admin']['merchant_admin_id'];
|
||||
@ -207,14 +193,7 @@ class MerchantIntentionRepository extends BaseRepository
|
||||
$store_service_data['phone'] = $intention['phone'];
|
||||
$store_service_data['create_time'] = date('Y-m-d H:i:s');
|
||||
Db::name('store_service')->insert($store_service_data);
|
||||
}
|
||||
if ($intention['type'] == 2) {
|
||||
$merId = Merchant::where('uid', $intention['uid'])->value('mer_id');
|
||||
if (!empty($merId)) {
|
||||
Merchant::where('mer_id', $merId)->update(['business_status' => 2, 'mer_settlement_agree_status' => 1]);
|
||||
}
|
||||
}
|
||||
if (!empty($smsData)) {
|
||||
|
||||
Queue::push(SendSmsJob::class, ['tempId' => 'APPLY_MER_SUCCESS', 'id' => $smsData]);
|
||||
}
|
||||
} else {
|
||||
|
@ -14,7 +14,6 @@
|
||||
namespace app\common\repositories\system\merchant;
|
||||
|
||||
|
||||
use app\common\dao\store\StoreCategoryDao;
|
||||
use app\common\dao\system\financial\FinancialDao;
|
||||
use app\common\dao\system\merchant\MerchantDao;
|
||||
use app\common\dao\system\serve\ServeOrderDao;
|
||||
@ -110,7 +109,7 @@ class MerchantRepository extends BaseRepository
|
||||
'merchantType'
|
||||
])
|
||||
->order('mer_id','desc')
|
||||
->field('sort, mer_id, mer_name, real_name, mer_phone, mer_address, mark, status, create_time,is_best,is_trader,type_id,category_id,copy_product_num,export_dump_num,is_margin,margin,mer_avatar,sale_amount,purchase_amount')->select();
|
||||
->field('sort, mer_id, mer_name, real_name, mer_phone, mer_address, mark, status, create_time,is_best,is_trader,type_id,category_id,copy_product_num,export_dump_num,is_margin,margin,mer_avatar')->select();
|
||||
return compact('count', 'list');
|
||||
}
|
||||
|
||||
@ -411,17 +410,12 @@ class MerchantRepository extends BaseRepository
|
||||
/**
|
||||
* @Author:Qinii
|
||||
* @Date: 2020/5/30
|
||||
* @param int $merId
|
||||
* @param int $pid
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function categoryList(int $merId, int $pid = 0)
|
||||
public function categoryList(int $id)
|
||||
{
|
||||
if ($pid == 0) {
|
||||
return app()->make(StoreCategoryRepository::class)->getApiFormatList($merId, 1);
|
||||
} else {
|
||||
return app()->make(StoreCategoryDao::class)->children($pid, $merId);
|
||||
}
|
||||
return app()->make(StoreCategoryRepository::class)->getApiFormatList($id, 1);
|
||||
}
|
||||
|
||||
public function wxQrcode($merId)
|
||||
@ -509,7 +503,7 @@ class MerchantRepository extends BaseRepository
|
||||
{
|
||||
if ($money <= 0) return;
|
||||
$payType = StoreOrder::getInstance()->where('order_id', $orderId)->value('pay_type');
|
||||
if (systemConfig('mer_lock_time') ||in_array($payType,[StoreGroupOrder::PAY_TYPE_BALANCE, StoreGroupOrder::PAY_TYPE_MER_BALANCE, StoreGroupOrder::PAY_TYPE_WECHAT,StoreGroupOrder::PAY_TYPE_CREDIT_BUY])) {
|
||||
if (systemConfig('mer_lock_time') ||in_array($payType,[StoreGroupOrder::PAY_TYPE_BALANCE,StoreGroupOrder::PAY_TYPE_WECHAT,StoreGroupOrder::PAY_TYPE_CREDIT_BUY])) {
|
||||
app()->make(UserBillRepository::class)->incBill($merId, 'mer_lock_money', $orderType, [
|
||||
'link_id' => ($orderType === 'order' ? 1 : 2) . $orderId,
|
||||
'mer_id' => $merId,
|
||||
@ -603,42 +597,6 @@ class MerchantRepository extends BaseRepository
|
||||
});
|
||||
}
|
||||
|
||||
public function computedSupplyLockMoney($order)
|
||||
{
|
||||
Db::transaction(function () use ($order) {
|
||||
$money = 0;
|
||||
/** @var UserBillRepository $make */
|
||||
$make = app()->make(UserBillRepository::class);
|
||||
$bills = $make->search(['mer_id' => $order['mer_id'], 'category' => 'mer_lock_money', 'type' => 'order', 'link_id' => '1' . $order->order_id, 'status' => 0])->select();
|
||||
foreach ($bills as $bill) {
|
||||
if ($bill) {
|
||||
$money = bcsub($bill->number, $make->refundMerchantMoney($bill->link_id, $bill->type, $bill->mer_id), 2);
|
||||
if ($order->presellOrder) {
|
||||
$presellBill = $make->search(['category' => 'mer_lock_money', 'type' => 'presell', 'link_id' => '2' . $order->presellOrder->presell_order_id, 'status' => 0])->find();
|
||||
if ($presellBill) {
|
||||
$money = bcadd($money, bcsub($presellBill->number, $make->refundMerchantMoney($presellBill->link_id, $presellBill->type, $presellBill->mer_id), 2), 2);
|
||||
$presellBill->status = 1;
|
||||
$presellBill->save();
|
||||
}
|
||||
}
|
||||
$bill->status = 1;
|
||||
$bill->save();
|
||||
}
|
||||
if ($money > 0) {
|
||||
app()->make(UserBillRepository::class)->incBill($bill->uid, 'mer_computed_money', 'order', [
|
||||
'link_id' => $order->order_id,
|
||||
'mer_id' => $bill->mer_id,
|
||||
'status' => 0,
|
||||
'title' => '商户待解冻余额',
|
||||
'number' => $money,
|
||||
'mark' => '交易完成,商户待解冻余额' . floatval($money) . '元',
|
||||
'balance' => 0
|
||||
]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function checkMargin($merId, $typeId)
|
||||
{
|
||||
$merchant = $this->dao->get($merId);
|
||||
@ -812,13 +770,13 @@ class MerchantRepository extends BaseRepository
|
||||
}
|
||||
$rate = $this->forceMargin ? 100 : $merchant['auto_margin_rate'];
|
||||
// //商户押金未完全缴纳且设置了自动扣除比例
|
||||
$margin = bcmul($income, bcdiv($rate, 100,2), 2);
|
||||
$margin = min(bcsub($merchant['margin'], $merchant['paid_margin'], 2), $margin);
|
||||
$income = max(bcsub($income, $margin, 2), 0);
|
||||
if ($margin <= 0) {
|
||||
return [$income, $financeDao];
|
||||
}
|
||||
$financeDao->platformIn($margin, 'auto_margin', $this->merId);
|
||||
$margin= bcmul($income, bcdiv($rate, 100,2), 2);
|
||||
// $margin = min(bcsub($margin, $merchant['paid_margin'], 2), $margin);
|
||||
// $income = max(bcsub($income, $margin, 2), 0);
|
||||
// if ($margin <= 0) {
|
||||
// return [$income, $financeDao];
|
||||
// }
|
||||
$financeDao->publicOut($margin, 'auto_margin', $this->merId);
|
||||
if(bcadd($merchant['paid_margin'],$margin)>=$merchant['margin']){
|
||||
$is_margin=10;
|
||||
}else{
|
||||
@ -852,36 +810,7 @@ class MerchantRepository extends BaseRepository
|
||||
throw new \Exception('merchant 保存出错', 500);
|
||||
}
|
||||
|
||||
return [$income, $financeDao];
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动扣除押金
|
||||
* @param $income
|
||||
* @param FinancialDao $financeDao
|
||||
* @return array
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function refundDeposit($income, FinancialDao $financeDao)
|
||||
{
|
||||
$merchant = Merchant::find($this->merId);
|
||||
$rate = $this->forceMargin ? 100 : $merchant['auto_margin_rate'];
|
||||
$margin = bcmul($income, bcdiv($rate, 100,2), 2);
|
||||
$merchant->paid_margin = bcsub($merchant->paid_margin, $margin, 2);
|
||||
if ($merchant->paid_margin <= 0) {
|
||||
return [bcsub($income,$margin,2), $financeDao];
|
||||
}
|
||||
if ($merchant->paid_margin < $merchant['margin'] && $merchant->is_margin == 10) {
|
||||
$merchant->is_margin = 1;
|
||||
}
|
||||
$merchant->ot_margin = $merchant->paid_margin;
|
||||
if ($merchant->save() === false) {
|
||||
throw new \Exception('merchant 保存出错', 500);
|
||||
}
|
||||
$financeDao->platformOut($margin, 'auto_margin_refund', $this->merId);
|
||||
return [$margin, $financeDao];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,10 +13,7 @@
|
||||
|
||||
namespace app\common\repositories\user;
|
||||
|
||||
use app\common\dao\store\consumption\StoreConsumptionUserDao;
|
||||
use app\common\dao\user\UserRechargeDao;
|
||||
use app\common\model\store\consumption\StoreConsumption;
|
||||
use app\common\model\store\consumption\StoreConsumptionUser;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserRecharge;
|
||||
use app\common\repositories\BaseRepository;
|
||||
@ -129,41 +126,8 @@ class UserRechargeRepository extends BaseRepository
|
||||
$recharge->user->now_money = bcadd($recharge->user->now_money, $price, 2);
|
||||
$recharge->user->save();
|
||||
$recharge->save();
|
||||
|
||||
$consumption = StoreConsumption::where('status', 1)->where('type', StoreConsumption::TYPE_RECHARGE)->find();
|
||||
if (!empty($consumption)) {
|
||||
$amount = min($recharge->price, 100000);
|
||||
$rate = $this->getRate($amount);
|
||||
$storeConsumptionUserDao = new StoreConsumptionUserDao();
|
||||
$storeConsumptionUserDao->send($consumption, $rate, $recharge->uid, $recharge->recharge_id, $amount, StoreConsumptionUser::STATUS_UNUSED, StoreConsumptionUser::TYPE_TWO);
|
||||
}
|
||||
});
|
||||
Queue::push(SendSmsJob::class,['tempId' => 'USER_BALANCE_CHANGE', 'id' =>$orderId]);
|
||||
event('user.recharge',compact('recharge'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 按充值金额获取赠送比例
|
||||
* @param $amount
|
||||
* @return int
|
||||
*/
|
||||
public function getRate($amount)
|
||||
{
|
||||
$rateArray = [
|
||||
['start' => 1000, 'end' => 4999, 'rate' => 0.05],
|
||||
['start' => 5000, 'end' => 9999, 'rate' => 0.1],
|
||||
['start' => 10000, 'end' => 49999, 'rate' => 0.15],
|
||||
['start' => 50000, 'end' => 100000, 'rate' => 0.2],
|
||||
];
|
||||
$rate = 0;
|
||||
foreach ($rateArray as $item) {
|
||||
if ($amount >=$item['start'] && $amount <= $item['end']) {
|
||||
$rate = $item['rate'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $rate;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -927,7 +927,7 @@ class UserRepository extends BaseRepository
|
||||
*/
|
||||
public function bindSpread(User $user, int $spreadUid)
|
||||
{
|
||||
if ($spreadUid && !$user->spread_uid && $user->uid != $spreadUid && ($spread = $this->dao->get($spreadUid)) && $spread->spread_uid != $user->uid && !$spread->cancel_time && $spread->is_promoter == 1) {
|
||||
if ($spreadUid && !$user->spread_uid && $user->uid != $spreadUid && ($spread = $this->dao->get($spreadUid)) && $spread->spread_uid != $user->uid && !$spread->cancel_time) {
|
||||
$config = systemConfig(['extension_limit', 'extension_limit_day', 'integral_user_give']);
|
||||
event('user.spread.before', compact('user','spreadUid'));
|
||||
Db::transaction(function () use ($spread, $spreadUid, $user, $config) {
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
namespace app\controller\admin\order;
|
||||
|
||||
use app\common\repositories\system\merchant\FinancialRecordRepository;
|
||||
use crmeb\basic\BaseController;
|
||||
use app\common\repositories\store\ExcelRepository;
|
||||
use app\common\repositories\system\merchant\MerchantRepository;
|
||||
@ -202,18 +201,4 @@ class Order extends BaseController
|
||||
$data = $this->repository->childrenList($id, 0);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单资金流水
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function financeRecord($id)
|
||||
{
|
||||
/** @var FinancialRecordRepository $repo */
|
||||
$repo = app()->make(FinancialRecordRepository::class);
|
||||
$data = $repo->getList(['order_id' => $id], 1, 9999);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class ProductLabel extends BaseController
|
||||
|
||||
public function create(ProductLabelValidate $validate)
|
||||
{
|
||||
$data = $this->request->params(['label_name', 'status', 'sort', 'info', 'value']);
|
||||
$data = $this->request->params(['label_name', 'status', 'sort', 'info']);
|
||||
$validate->check($data);
|
||||
if (!$this->repository->check($data['label_name'], 0))
|
||||
return app('json')->fail('名称重复');
|
||||
@ -56,7 +56,7 @@ class ProductLabel extends BaseController
|
||||
|
||||
public function update($id, ProductLabelValidate $validate)
|
||||
{
|
||||
$data = $this->request->params(['label_name', 'status', 'sort', 'info', 'value']);
|
||||
$data = $this->request->params(['label_name', 'status', 'sort', 'info']);
|
||||
$validate->check($data);
|
||||
if (!$this->repository->check($data['label_name'], 0,$id))
|
||||
return app('json')->fail('名称重复');
|
||||
|
@ -57,33 +57,10 @@ class StoreProduct extends BaseController
|
||||
$_where = $this->repository->switchType($where['type'], null, 0);
|
||||
unset($_where['product_type']);
|
||||
unset($_where['star']);
|
||||
$where['order'] = "check";//标识后台查询更新时间倒叙
|
||||
$where = array_merge($where, $_where);
|
||||
return app('json')->success($this->repository->getAdminList($merId, $where, $page, $limit));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function excel()
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$where = $this->request->params(['cate_id', 'keyword', ['type', 1], 'mer_cate_id', 'pid', 'store_name', 'is_trader', 'us_status', 'product_id', 'star', 'sys_labels', 'hot_type', 'svip_price_type']);
|
||||
$mer_id = $this->request->param('mer_id', '');
|
||||
$merId = $mer_id ? $mer_id : null;
|
||||
$where['is_gift_bag'] = 0;
|
||||
$_where = $this->repository->switchType($where['type'], null, 0);
|
||||
unset($_where['product_type']);
|
||||
unset($_where['star']);
|
||||
$where['order'] = "check";//标识后台查询更新时间倒叙
|
||||
$where = array_merge($where, $_where);
|
||||
|
||||
$data = $this->repository->getGoodsList($merId, $where, $page, $limit);
|
||||
return app('json')->success($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author:Qinii
|
||||
* @Date: 2020/5/18
|
||||
@ -329,30 +306,30 @@ class StoreProduct extends BaseController
|
||||
public function copy($product_id = 0, $mer_id = 0, $street_code = 0, $type_id = 0, $category_id = 0)
|
||||
{
|
||||
if ($product_id == 0) return app('json')->fail('参数错误');
|
||||
// $find= Db::name('merchant')->where('mer_id',$mer_id)->find();
|
||||
$find= Db::name('merchant')->where('mer_id',$mer_id)->find();
|
||||
$products = $this->repository->getAdminOneProduct($product_id, 0);
|
||||
$product = $products->toArray();
|
||||
$product['mer_id'] = $mer_id;
|
||||
$product['old_product_id'] = $product['product_id'];
|
||||
$productId = $this->repository->create($product, 0, 1);
|
||||
// $data = [
|
||||
// 'product_id' => $productId,
|
||||
// 'mer_id' => $mer_id,
|
||||
// 'source_mer_id' => $products['mer_id'],
|
||||
// 'street_code' => $street_code,
|
||||
// 'weight' => 1,
|
||||
// 'status' => 1,
|
||||
// 'create_time' => date('Y-m-d H:i:s'),
|
||||
// 'type_id' => $type_id,
|
||||
// 'category_id' => $category_id,
|
||||
// 'cate_id' => 2244,
|
||||
// 'long' => $find['long'],
|
||||
// 'lat' => $find['lat'],
|
||||
// 'lat' => $find['lat'],
|
||||
// 'store_name' => $products['store_name'],
|
||||
// 'activity_id' =>2,
|
||||
// ];
|
||||
// Db::name('cloud_product')->insert($data);
|
||||
$data = [
|
||||
'product_id' => $productId,
|
||||
'mer_id' => $mer_id,
|
||||
'source_mer_id' => $products['mer_id'],
|
||||
'street_code' => $street_code,
|
||||
'weight' => 1,
|
||||
'status' => 1,
|
||||
'create_time' => date('Y-m-d H:i:s'),
|
||||
'type_id' => $type_id,
|
||||
'category_id' => $category_id,
|
||||
'cate_id' => 2244,
|
||||
'long' => $find['long'],
|
||||
'lat' => $find['lat'],
|
||||
'lat' => $find['lat'],
|
||||
'store_name' => $products['store_name'],
|
||||
'activity_id' =>2,
|
||||
];
|
||||
Db::name('cloud_product')->insert($data);
|
||||
return $productId;
|
||||
}
|
||||
}
|
||||
|
@ -149,22 +149,9 @@ class Financial extends BaseController
|
||||
{
|
||||
$where = $this->request->params(['date', 'status', 'financial_type', 'financial_status', 'keyword', 'is_trader', 'mer_id']);
|
||||
[$page, $limit] = $this->getPage();
|
||||
/** @var ExcelService $make */
|
||||
$make = app()->make(ExcelService::class);
|
||||
$data = $make->financialLog($where,$page,$limit);
|
||||
$data = app()->make(ExcelService::class)->financialLog($where,$page,$limit);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
|
||||
public function billExport()
|
||||
{
|
||||
$where = $this->request->params(['date', 'status', 'financial_type', 'financial_status', 'keyword', 'is_trader', 'mer_id']);
|
||||
[$page, $limit] = $this->getPage();
|
||||
$data = app()->make(ExcelService::class)->withdrawalBill($where,$page,$limit);
|
||||
return app('json')->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -37,9 +37,14 @@ class FinancialRecord extends BaseController
|
||||
$merId = $this->request->merId();
|
||||
if ($merId) {
|
||||
$where['mer_id'] = $merId;
|
||||
$where['financial_type'] = array_merge($this->repository->commonFinancialType, ['mer_accoubts']);
|
||||
$where['financial_type'] = ['order', 'mer_accoubts', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon',
|
||||
'order_svip_coupon','commission_to_service_team','commission_to_service_team_refund','commission_to_platform','commission_to_platform_refund','commission_to_village','commission_to_village_refund','commission_to_town','commission_to_town_refund','commission_to_entry_merchant','commission_to_entry_merchant_refund'
|
||||
,'commission_to_cloud_warehouse','commission_to_cloud_warehouse_refund'];
|
||||
} else {
|
||||
$where['financial_type'] = array_merge($this->repository->commonFinancialType, ['sys_accoubts']);
|
||||
$where['financial_type'] = ['order', 'sys_accoubts', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon',
|
||||
'order_svip_coupon','commission_to_service_team','commission_to_service_team_refund','commission_to_platform','commission_to_platform_refund','commission_to_village','commission_to_village_refund','commission_to_town','commission_to_town_refund'
|
||||
,'commission_to_entry_merchant','commission_to_entry_merchant_refund'
|
||||
,'commission_to_cloud_warehouse','commission_to_cloud_warehouse_refund'];
|
||||
}
|
||||
return app('json')->success($this->repository->getList($where, $page, $limit));
|
||||
}
|
||||
@ -161,28 +166,4 @@ class FinancialRecord extends BaseController
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO 导出文件
|
||||
* @param $type
|
||||
* @author Qinii
|
||||
* @day 3/25/21
|
||||
*/
|
||||
public function exportDetail2($type)
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$date = $this->request->param('date');
|
||||
$where['date'] = empty($date) ? date('Y-m-d',time()) : $date ;
|
||||
$where['type'] = $type;
|
||||
$where['is_mer'] = $this->request->merId() ?? 0 ;
|
||||
try {
|
||||
$merchant = $this->request->merchant();
|
||||
}catch (\Exception $e){
|
||||
$merchant = [];
|
||||
}
|
||||
/** @var ExcelService $make */
|
||||
$make = app()->make(ExcelService::class);
|
||||
$data = $make->exportFinancial2($where,$page,$limit,$merchant);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class MerchantIntention extends BaseController
|
||||
public function lst()
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$where = $this->request->params(['mer_name', 'status', 'date', 'keyword', 'mer_intention_id', 'category_id', 'type_id', 'type']);
|
||||
$where = $this->request->params(['mer_name', 'status', 'date', 'keyword', 'mer_intention_id', 'category_id', 'type_id']);
|
||||
return app('json')->success($this->repository->getList($where, $page, $limit));
|
||||
}
|
||||
|
||||
|
@ -14,18 +14,6 @@
|
||||
namespace app\controller\api;
|
||||
|
||||
|
||||
use app\common\model\store\consumption\StoreConsumptionDetail;
|
||||
use app\common\model\store\consumption\StoreConsumptionUser;
|
||||
use app\common\model\store\order\StoreGroupOrder;
|
||||
use app\common\model\store\order\StoreOrder;
|
||||
use app\common\model\store\order\StoreOrderOther;
|
||||
use app\common\model\store\order\StoreOrderProduct;
|
||||
use app\common\model\store\order\StoreOrderStatus;
|
||||
use app\common\model\store\order\StoreRefundOrder;
|
||||
use app\common\model\system\merchant\FinancialRecord;
|
||||
use app\common\model\user\UserAddress;
|
||||
use app\common\model\user\UserBill;
|
||||
use app\common\model\user\UserRecharge;
|
||||
use app\common\repositories\store\order\StoreOrderRepository;
|
||||
use app\common\repositories\store\order\StoreRefundOrderRepository;
|
||||
use app\common\repositories\system\notice\SystemNoticeConfigRepository;
|
||||
@ -53,7 +41,6 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use think\db\Query;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Db;
|
||||
@ -381,21 +368,20 @@ class Auth extends BaseController
|
||||
$store_service = Db::name('store_service')->where('uid', $data['uid'])->find();
|
||||
|
||||
if ($store_service) {
|
||||
$mer_arr = Db::name('merchant')->where('mer_id', $store_service['mer_id'])->where('is_del', 0)->field('type_id,mer_avatar,mer_banner,business_status,mer_info,category_id,service_phone,mer_address,uid,mer_name,create_time,update_time,mer_settlement_agree_status,is_margin,street_id,is_company,mer_money')->find();
|
||||
$mer_arr = Db::name('merchant')->where('mer_id', $store_service['mer_id'])->where('is_del', 0)->field('type_id,mer_avatar,mer_banner,business_status,mer_info,category_id,service_phone,mer_address,uid,mer_name,create_time,update_time,mer_settlement_agree_status,is_margin,street_id,is_company')->find();
|
||||
$bank_info = Db::name('merchant_intention')->where('mer_id', $store_service['mer_id'])->field('company_name,bank_username,bank_opening,bank_code')->find();
|
||||
if ($mer_arr && $mer_arr['mer_avatar'] != '' && $mer_arr['mer_banner'] != '' && $mer_arr['mer_info'] && $mer_arr['service_phone'] != '' && $mer_arr['mer_address'] != '') {
|
||||
$data['is_wsxx'] = 1;
|
||||
}
|
||||
if($bank_info && count($bank_info)>0 && count($mer_arr)>0){
|
||||
if($bank_info){
|
||||
$data['mer_info'] = array_merge($mer_arr,$bank_info);
|
||||
}else{
|
||||
$data['mer_info'] =$mer_arr;
|
||||
}
|
||||
$merType = Db::name('merchant_type')->where('mer_type_id', $mer_arr['type_id'] ?? 0)->field('type_code,type_name')->find();
|
||||
$data['mer_info']['type_code'] = $merType['type_code'];
|
||||
$data['mer_info']['type_name'] = $merType['type_name'];
|
||||
$typCode = Db::name('merchant_type')->where('mer_type_id', $mer_arr['type_id'] ?? 0)->value('type_code');
|
||||
$data['mer_info']['type_code'] = $typCode;
|
||||
$data['mer_info']['setting_status'] = 0;
|
||||
if (!empty($mer_arr['mer_avatar']) && !empty($mer_arr['mer_banner']) && !empty($mer_arr['mer_address'])) {
|
||||
if (($mer_arr['update_time'] ?? '') > ($mer_arr['create_time'] ?? '')) {
|
||||
$data['mer_info']['setting_status'] = 1;
|
||||
}
|
||||
}
|
||||
@ -748,22 +734,20 @@ class Auth extends BaseController
|
||||
if (!$sms_code && !env('APP_DEBUG')) return app('json')->fail('验证码不正确');
|
||||
$user = $repository->accountByUser($data['phone']);
|
||||
$auth = $this->parseAuthToken($data['auth_token']);
|
||||
$isNewUser = false;
|
||||
if (!$user) {
|
||||
$isNewUser = true;
|
||||
$user = $repository->registr($data['phone'], null, $data['user_type']);
|
||||
}
|
||||
$spreadId = empty($data['spread']) ? $user['spread_uid'] : $data['spread'];
|
||||
if ($auth && !$user['wechat_user_id']) {
|
||||
$repository->syncBaseAuth($auth, $user);
|
||||
}
|
||||
$user = $repository->mainUser($user);
|
||||
$repository->bindSpread($user, intval($spreadId));
|
||||
$repository->bindSpread($user, intval($data['spread']));
|
||||
|
||||
$tokenInfo = $repository->createToken($user);
|
||||
$repository->loginAfter($user);
|
||||
|
||||
return app('json')->success(array_merge(['is_new_user' => $isNewUser], $repository->returnToken($user, $tokenInfo)));
|
||||
return app('json')->success(array_merge(['is_new_user' => $isNewUser ?? false], $repository->returnToken($user, $tokenInfo)));
|
||||
}
|
||||
|
||||
public function changePassword(ChangePasswordValidate $validate, UserRepository $repository)
|
||||
@ -889,10 +873,9 @@ class Auth extends BaseController
|
||||
throw new ValidateException('授权失败[003]');
|
||||
return $user;
|
||||
} else if ($auth['type'] === 'app_wechat') {
|
||||
$oauth = WechatService::create(true)->getApplication()->oauth;
|
||||
$accessToken = $oauth->getAccessToken($data['code']);
|
||||
$oauth = WechatService::create()->getApplication()->oauth;
|
||||
try {
|
||||
$wechatInfo = $oauth->user($accessToken)->getOriginal();
|
||||
$wechatInfo = $oauth->user(new AccessToken(['access_token' => $data['code'], 'openid' => $data['openid']]))->getOriginal();
|
||||
} catch (Exception $e) {
|
||||
throw new ValidateException('授权失败[001]' . $e->getMessage());
|
||||
}
|
||||
@ -925,15 +908,10 @@ class Auth extends BaseController
|
||||
public function authLogin()
|
||||
{
|
||||
$auth = $this->request->param('auth');
|
||||
$createUser = true;
|
||||
if ($auth['type'] == 'app_wechat' || systemConfig('is_phone_login') == '1') {
|
||||
$createUser = false;
|
||||
}
|
||||
$users = $this->authInfo($auth, $createUser);
|
||||
$users = $this->authInfo($auth, systemConfig('is_phone_login') !== '1');
|
||||
if (!$users)
|
||||
return app('json')->fail('授权失败');
|
||||
$authInfo = $users[0];
|
||||
/** @var UserRepository $userRepository */
|
||||
$userRepository = app()->make(UserRepository::class);
|
||||
$user = $users[1] ?? $userRepository->wechatUserIdBytUser($authInfo['wechat_user_id']);
|
||||
$code = (int)($auth['auth']['spread_code']['id'] ?? $auth['auth']['spread_code'] ?? '');
|
||||
@ -941,7 +919,7 @@ class Auth extends BaseController
|
||||
if ($code && ($info = app()->make(RoutineQrcodeRepository::class)->getRoutineQrcodeFindType($code))) {
|
||||
$auth['auth']['spread'] = $info['third_id'];
|
||||
}
|
||||
if ((!$user || empty($user['account']) || empty($user['phone'])) && $auth['type'] == 'app_wechat') {
|
||||
if (!$user) {
|
||||
$uni = uniqid(true, false) . random_int(1, 100000000);
|
||||
$key = 'U' . md5(time() . $uni);
|
||||
Cache::set('u_try' . $key, ['id' => $authInfo['wechat_user_id'], 'type' => $authInfo['user_type'], 'spread' => $auth['auth']['spread'] ?? 0], 3600);
|
||||
@ -951,9 +929,6 @@ class Auth extends BaseController
|
||||
if ($auth['auth']['spread'] ?? 0) {
|
||||
$userRepository->bindSpread($user, (int)($auth['auth']['spread']));
|
||||
}
|
||||
if (!empty($user['account'])) {
|
||||
$user = $userRepository->accountByUser($user['account']);
|
||||
}
|
||||
$tokenInfo = $userRepository->createToken($user);
|
||||
$userRepository->loginAfter($user);
|
||||
return app('json')->status(200, $userRepository->returnToken($user, $tokenInfo));
|
||||
@ -1582,7 +1557,7 @@ class Auth extends BaseController
|
||||
// $phoneBrand = $this->request->param('phone_brand', '');
|
||||
// $queryBuilder = Db::name('AppUpdate')->where('type', $type);
|
||||
if ($type == 3) {
|
||||
$android = (Db::name('AppUpdate')->where('type', 1)->where('phone_brand', '')->where('is_wget',0)->order('id', 'desc')->find()) ?? (object)[];
|
||||
$android = (Db::name('AppUpdate')->where('type', 1)->where('phone_brand', '')->order('id', 'desc')->find()) ?? (object)[];
|
||||
$ios = (Db::name('AppUpdate')->where('type', 2)->where('phone_brand', '')->order('id', 'desc')->find()) ?? (object)[];
|
||||
return app('json')->success(compact('android', 'ios'));
|
||||
} else {
|
||||
@ -1675,110 +1650,4 @@ class Auth extends BaseController
|
||||
$data = $repository->getResult($type);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并账号
|
||||
* @param UserRepository $repository
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function merge(UserRepository $repository)
|
||||
{
|
||||
$data = $this->request->params(['phone', 'sms_code', 'spread', 'pwd', 'auth_token', ['user_type', 'h5']]);
|
||||
$sms_code = app()->make(SmsService::class)->checkSmsCode($data['phone'], $data['sms_code'], 'login');
|
||||
if (!$sms_code && !env('APP_DEBUG')) {
|
||||
return app('json')->fail('验证码不正确');
|
||||
}
|
||||
$auth = Cache::get('u_try' . $data['auth_token']);
|
||||
$auth && Cache::delete('u_try' . $data['auth_token']);
|
||||
if (empty($auth)) {
|
||||
return app('json')->fail('授权已过期,请重新登录');
|
||||
}
|
||||
$user = $repository->wechatUserIdBytUser($auth['id']);
|
||||
if (!empty($user['account']) && !empty($user['phone'])) {
|
||||
return app('json')->fail('已绑定手机号');
|
||||
}
|
||||
$targetUser = $repository->accountByUser($data['phone']);
|
||||
if (empty($targetUser)) {
|
||||
if (!empty($user)) {
|
||||
$user->account = $data['phone'];
|
||||
$user->phone = $data['phone'];
|
||||
$user->save();
|
||||
$tokenInfo = $repository->createToken($user);
|
||||
return app('json')->success($repository->returnToken($user, $tokenInfo));
|
||||
} else {
|
||||
$targetUser = $repository->registr($data['phone'], $data['pwd'], $data['user_type']);
|
||||
$repository->bindSpread($targetUser, intval($data['spread']));
|
||||
}
|
||||
}
|
||||
$repository->syncBaseAuth($auth, $targetUser);
|
||||
if (!empty($user)) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
$merchant = Merchant::where('uid', $targetUser['uid'])->find();
|
||||
if (!empty($merchant)) {
|
||||
$orders = StoreOrder::with(['refundOrder' => function(Query $query) {
|
||||
$query->where('status', '<>', -1)->field('order_id,refund_price');
|
||||
}])->where('uid', $user['uid'])
|
||||
->whereIn('status', [2, 3])
|
||||
->field('order_id,uid,total_price')
|
||||
->select()->toArray();
|
||||
$otherOrders = StoreOrderOther::with(['refundOrder' => function(Query $query) {
|
||||
$query->where('status', '<>', -1)->field('order_id,refund_price');
|
||||
}])->where('uid', $user['uid'])
|
||||
->whereIn('status', [2, 3])
|
||||
->field('order_id,uid,total_price')
|
||||
->select()->toArray();
|
||||
$purchaseAmount = 0;
|
||||
foreach ($orders as $order) {
|
||||
$purchaseAmount = bcadd($purchaseAmount, $order['total_price'], 2);
|
||||
foreach ($order['refundOrder']as $refundOrder) {
|
||||
$purchaseAmount = bcsub($purchaseAmount, $refundOrder['refund_price'], 2);
|
||||
}
|
||||
}
|
||||
unset($refundOrder, $order);
|
||||
foreach ($otherOrders as $otherOrder) {
|
||||
$purchaseAmount = bcadd($purchaseAmount, $otherOrder['total_price'], 2);
|
||||
foreach ($otherOrder['refundOrder']as $refundOrder) {
|
||||
$purchaseAmount = bcsub($purchaseAmount, $refundOrder['refund_price'], 2);
|
||||
}
|
||||
}
|
||||
unset($refundOrder, $otherOrder);
|
||||
if ($purchaseAmount > 0) {
|
||||
$merchant->purchase_amount = bcadd($merchant->purchase_amount, $purchaseAmount, 2);
|
||||
$merchant->save();
|
||||
}
|
||||
}
|
||||
StoreGroupOrder::where('uid', $user['uid'])->update(['uid' => $targetUser['uid']]);
|
||||
StoreOrder::where('uid', $user['uid'])->update(['uid' => $targetUser['uid']]);
|
||||
StoreOrderProduct::where('uid', $user['uid'])->update(['uid' => $targetUser['uid']]);
|
||||
UserBill::where('uid', $user['uid'])->update(['uid' => $targetUser['uid']]);
|
||||
FinancialRecord::where('user_id', $user['uid'])->update(['user_id' => $targetUser['uid']]);
|
||||
UserAddress::where('uid', $user['uid'])->update(['uid' => $targetUser['uid']]);
|
||||
StoreConsumptionUser::where('uid', $user['uid'])->update(['uid' => $targetUser['uid']]);
|
||||
StoreConsumptionDetail::where('user_id', $user['uid'])->update(['user_id' => $targetUser['uid']]);
|
||||
StoreRefundOrder::where('uid', $user['uid'])->update(['uid' => $targetUser['uid']]);
|
||||
UserRecharge::where('uid', $user['uid'])->update(['uid' => $targetUser['uid']]);
|
||||
StoreOrderStatus::where('uid', $user['uid'])->update(['uid' => $targetUser['uid']]);
|
||||
if ($user->now_money > 0) {
|
||||
$targetUser->now_money = bcadd($targetUser->now_money, $user->now_money, 2);
|
||||
$user->now_money = 0;
|
||||
$targetUser->save();
|
||||
}
|
||||
$user->wechat_user_id = 0;
|
||||
$user->account = 'uid_' . $targetUser['uid'];
|
||||
$user->status = -1;
|
||||
$user->save();
|
||||
Db::commit();
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new ValidateException('绑定出错');
|
||||
}
|
||||
}
|
||||
$tokenInfo = $repository->createToken($targetUser);
|
||||
return app('json')->success($repository->returnToken($targetUser, $tokenInfo));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -490,14 +490,7 @@ class Common extends BaseController
|
||||
}
|
||||
|
||||
//区县数据
|
||||
public function getCity($code = 510000)
|
||||
{
|
||||
$select = Db::name('geo_city')->where('province_code', $code)->field('city_id id,city_code code,city_name name')->select();
|
||||
return app('json')->success($select);
|
||||
}
|
||||
|
||||
//区县数据
|
||||
public function get_area($city_code = 510500)
|
||||
public function get_area($city_code)
|
||||
{
|
||||
$select = Db::name('geo_area')->where('city_code', $city_code)->field('area_id id,area_code code,area_name name')->select();
|
||||
return app('json')->success($select);
|
||||
@ -651,7 +644,7 @@ class Common extends BaseController
|
||||
public function Qrcode($data)
|
||||
{
|
||||
$siteUrl = systemConfig('site_url');
|
||||
$name = 'orcode'.$data['id'] .md5(date('code') . date('Ymd')) . '.png';
|
||||
$name = 'orcode'.$data['id'] .md5(date('Ymd')) . '.png';
|
||||
$attachmentRepository = app()->make(AttachmentRepository::class);
|
||||
$imageInfo = $attachmentRepository->getWhere(['attachment_name' => $name]);
|
||||
|
||||
|
@ -3,9 +3,7 @@
|
||||
namespace app\controller\api;
|
||||
|
||||
use app\common\dao\store\consumption\CommissionDao;
|
||||
use app\common\model\store\order\StoreOrder;
|
||||
use crmeb\basic\BaseController;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Log;
|
||||
|
||||
class Open extends BaseController
|
||||
@ -20,13 +18,20 @@ class Open extends BaseController
|
||||
*/
|
||||
public function activityCommission()
|
||||
{
|
||||
$decrypted = $this->decrypt();
|
||||
$timestamp = $this->request->post('timestamp');
|
||||
$data = $this->request->post('data');
|
||||
$aes = new \AES();
|
||||
$iv = !empty($timestamp) ? $aes->buildIv($timestamp) : '';
|
||||
$decrypted = $aes->decrypt($data, $iv);
|
||||
Log::error('供销平台佣金回调:' . var_export($decrypted, true));
|
||||
if (!empty($decrypted)) {
|
||||
$storeConsumptionUserDao = new CommissionDao();
|
||||
// "惠农供销,谱写数字新篇章"活动首单分润
|
||||
$result = $storeConsumptionUserDao->firstOrderCommissionCallback($decrypted);
|
||||
return app('json')->success($result);
|
||||
}
|
||||
return app('json')->fail('解密失败');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -37,37 +42,19 @@ class Open extends BaseController
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function refundCommission()
|
||||
{
|
||||
$decrypted = $this->decrypt();
|
||||
Log::error('供销平台退佣金回调:' . var_export($decrypted, true));
|
||||
$storeConsumptionUserDao = new CommissionDao();
|
||||
$result = $storeConsumptionUserDao->refundByCallback($decrypted);
|
||||
return app('json')->success($result);
|
||||
}
|
||||
|
||||
public function orderList()
|
||||
{
|
||||
$pageIndex = $this->request->get('page', 1);
|
||||
$pageSize = $this->request->get('page_size', 15);
|
||||
$order = StoreOrder::whereIn('status', [0, 1, 2, 3])
|
||||
->field('order_id,order_sn')
|
||||
->limit($pageIndex, $pageSize)
|
||||
->order('order_id', 'desc')
|
||||
->select()->toArray();
|
||||
return app('json')->success($order);
|
||||
}
|
||||
|
||||
public function decrypt()
|
||||
{
|
||||
$timestamp = $this->request->post('timestamp');
|
||||
$data = $this->request->post('data');
|
||||
$aes = new \AES();
|
||||
$iv = !empty($timestamp) ? $aes->buildIv($timestamp) : '';
|
||||
$decrypted = $aes->decrypt($data, $iv);
|
||||
if (empty($decrypted)) {
|
||||
throw new ValidateException('解密失败');
|
||||
Log::error('供销平台退佣金回调:' . var_export($decrypted, true));
|
||||
if (!empty($decrypted)) {
|
||||
$storeConsumptionUserDao = new CommissionDao();
|
||||
$result = $storeConsumptionUserDao->refundByCallback($decrypted);
|
||||
return app('json')->success($result);
|
||||
}
|
||||
return $decrypted;
|
||||
return app('json')->fail('解密失败');
|
||||
}
|
||||
|
||||
}
|
@ -50,14 +50,14 @@ class Order extends BaseController
|
||||
->leftJoin('merchant m', 'o.mer_id = m.mer_id')
|
||||
->leftJoin('store_order_product op', 'o.order_id = op.order_id')
|
||||
->leftJoin('store_product p', 'op.product_id = p.product_id')
|
||||
// ->whereDay('og.create_time', $day)
|
||||
->whereDay('og.create_time', $day)
|
||||
->where('o.paid', 1)
|
||||
->whereNotNull('o.pay_time');
|
||||
|
||||
// 待取货订单数统计query 订单待发货
|
||||
$pendingPickupOrderCountQuery = Db::name('store_order')->alias('o')
|
||||
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
|
||||
// ->whereDay('og.create_time', $day)
|
||||
->whereDay('og.create_time', $day)
|
||||
->where('o.status', 0)
|
||||
->where('o.paid', 1)
|
||||
->whereNotNull('o.pay_time');;
|
||||
@ -65,7 +65,7 @@ class Order extends BaseController
|
||||
// 未配送订单数统计query 订单待收货
|
||||
$undeliveredOrderCountQuery = Db::name('store_order')->alias('o')
|
||||
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
|
||||
// ->whereDay('og.create_time', $day)
|
||||
->whereDay('og.create_time', $day)
|
||||
->where('o.status', 1)
|
||||
->where('o.paid', 1)
|
||||
->whereNotNull('o.pay_time');;
|
||||
@ -73,7 +73,7 @@ class Order extends BaseController
|
||||
// 已完成订单数统计query 订单已完成
|
||||
$doneOrderCountQuery = Db::name('store_order')->alias('o')
|
||||
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
|
||||
// ->whereDay('og.create_time', $day)
|
||||
->whereDay('og.create_time', $day)
|
||||
->whereIn('o.status', [2,3])
|
||||
->where('o.paid', 1)
|
||||
->whereNotNull('o.pay_time');
|
||||
|
@ -1,194 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller\api\server;
|
||||
|
||||
use app\common\model\store\consumption\StoreConsumption;
|
||||
use app\common\model\store\consumption\StoreConsumptionUser;
|
||||
use app\common\model\system\merchant\FinancialRecord;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\model\user\UserBill;
|
||||
use app\controller\api\Common;
|
||||
use crmeb\basic\BaseController;
|
||||
use think\App;
|
||||
use think\db\Query;
|
||||
|
||||
class Store extends BaseController
|
||||
{
|
||||
|
||||
protected $merId;
|
||||
|
||||
public function __construct(App $app)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->merId = $this->request->route('merId');
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成二维码
|
||||
*/
|
||||
public function qrcode()
|
||||
{
|
||||
$common = app()->make(Common::class);
|
||||
$siteUrl = systemConfig('site_url');
|
||||
$data = $common->Qrcode(['code' => $siteUrl . 'download/index.html?code=mer_' . $this->merId, 'id' => $this->merId]);
|
||||
return app('json')->success(['url' => $data]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 邀请记录
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function record()
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$query = FinancialRecord::field('order_sn,number')
|
||||
->where('mer_id', $this->merId)
|
||||
->where('financial_type', 'commission_to_promoter')
|
||||
->with(['orderInfo' => function (Query $query) {
|
||||
$query->field('pay_price,real_name,uid,order_sn')->with(['user' => function (Query $query) {
|
||||
$query->field('nickname,uid');
|
||||
}]);
|
||||
}]);
|
||||
$count = $query->count();
|
||||
$result = $query->page($page, $limit)->select()->toArray();
|
||||
$list = [];
|
||||
foreach ($result as $item) {
|
||||
$list[] = [
|
||||
'nickname' => $item['orderInfo']['user']['nickname'],
|
||||
'uid' => $item['orderInfo']['uid'],
|
||||
'order_amount' => $item['orderInfo']['pay_price'],
|
||||
'commission' => $item['number'],
|
||||
];
|
||||
}
|
||||
return app('json')->success(['count' => $count, 'list' => $list]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 补贴进度查询
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function subsidy()
|
||||
{
|
||||
$type = $this->request->get('type', 1);
|
||||
$uid = $this->request->uid();
|
||||
$merchant = Merchant::where('mer_id', $this->merId)->field('sale_amount,purchase_amount,type_id')->find()->toArray();
|
||||
$saleTarget = '0.00';
|
||||
$purchaseTarget = '0.00';
|
||||
if ($type == 1) {
|
||||
//春耕采购补贴
|
||||
$couponId = StoreConsumption::where('type', StoreConsumption::TYPE_PULL_CONSUMPTION)->value('coupon_id');
|
||||
$userConsumption = StoreConsumptionUser::where('uid', $uid)
|
||||
->where('coupon_id', $couponId)
|
||||
->where('status', '<>', -1)
|
||||
->field('coupon_price,balance')
|
||||
->find();
|
||||
if (!empty($userConsumption)) {
|
||||
$couponId = StoreConsumption::where('type', StoreConsumption::TYPE_RECHARGE)->value('coupon_id');
|
||||
$subsidyAmount = StoreConsumptionUser::where('uid', $uid)
|
||||
->where('coupon_id', $couponId)
|
||||
->value('coupon_price');
|
||||
$saleTarget = $userConsumption['coupon_price'];
|
||||
$purchaseTarget = $userConsumption['coupon_price'];
|
||||
$merchant['purchase_amount'] = bcsub($userConsumption['coupon_price'], $userConsumption['balance'], 2);
|
||||
$merchant['balance'] = $userConsumption['balance'];
|
||||
}
|
||||
} else {
|
||||
//增收销售补贴
|
||||
$consumption = StoreConsumption::where('type', StoreConsumption::TYPE_SALE_SUBSIDY)->find();
|
||||
if ($consumption) {
|
||||
$userConsumption = StoreConsumptionUser::where('uid', $uid)
|
||||
->where('coupon_id', $consumption['coupon_id'])
|
||||
->where('status', '<>', -1)
|
||||
->field('coupon_price,balance,status')
|
||||
->find();
|
||||
$subsidyAmount = $userConsumption['coupon_price'] ?? '0.00';
|
||||
$merchant['balance'] = $userConsumption['balance'] ?? '0.00';
|
||||
foreach ($consumption['config'] as $k => $item) {
|
||||
if (empty($userConsumption) && in_array($merchant['type_id'], $item['type_id'])) {
|
||||
$saleTarget = $item['amount'];
|
||||
$subsidyAmount = $item['subsidy'];
|
||||
$purchaseTarget = bcmul($saleTarget, 0.5, 2);
|
||||
break;
|
||||
}
|
||||
if (!empty($userConsumption) && in_array($merchant['type_id'], $item['type_id'])) {
|
||||
$nextItem = $consumption['config'][$k + 1] ?? $item;
|
||||
$saleTarget = $nextItem['amount'];
|
||||
$subsidyAmount = $nextItem['subsidy'];
|
||||
$purchaseTarget = bcmul($saleTarget, 0.5, 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$saleFinishRate = $saleTarget <= 0 ? 0 : bcdiv($merchant['sale_amount'], $saleTarget, 2);
|
||||
$saleFinishRate = bcmul(min($saleFinishRate, 1), 100, 0);
|
||||
$purchaseFinishRate = $purchaseTarget <= 0 ? 0 : bcdiv($merchant['purchase_amount'], $purchaseTarget, 2);
|
||||
$purchaseFinishRate = bcmul(min($purchaseFinishRate, 1), 100, 0);
|
||||
$springSubsidyRate = $purchaseTarget <= 0 ? 0 : bcdiv($merchant['purchase_amount'], $purchaseTarget, 2);
|
||||
$springSubsidyRate = bcmul(min($springSubsidyRate, 1), 100, 0);
|
||||
return app('json')->success([
|
||||
'subsidy_amount' => empty($subsidyAmount) ? '0.00' : $subsidyAmount,
|
||||
'subsidy_status' => $saleFinishRate >= 100 && $purchaseFinishRate >= 100,
|
||||
'sale_target' => $saleTarget,
|
||||
'sale_amount' => $merchant['sale_amount'],
|
||||
'sale_finish_rate' => $saleFinishRate,
|
||||
'purchase_target' => $purchaseTarget,
|
||||
'purchase_amount' => $merchant['purchase_amount'],
|
||||
'purchase_finish_rate' => $purchaseFinishRate,
|
||||
'spring_subsidy' => $saleTarget,
|
||||
'spring_subsidy_amount' => $merchant['purchase_amount'],
|
||||
'spring_subsidy_rate' => $springSubsidyRate,
|
||||
'balance' => $merchant['balance'] ?? '0.00',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 红包获取记录
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function subsidyRecord()
|
||||
{
|
||||
$userId = $this->request->uid();
|
||||
$type = $this->request->get('type', 1);
|
||||
$page = $this->request->get('page', 1);
|
||||
$limit = $this->request->get('limit', 10);
|
||||
if ($type == 1) {
|
||||
$couponType = StoreConsumption::TYPE_RECHARGE;
|
||||
} else {
|
||||
$couponType = StoreConsumption::TYPE_SALE_SUBSIDY;
|
||||
}
|
||||
$couponId = StoreConsumption::where('type', $couponType)->value('coupon_id');
|
||||
$totalAmount = StoreConsumptionUser::where('uid', $userId)
|
||||
->whereIn('coupon_id', $couponId)
|
||||
->where('status', StoreConsumptionUser::STATUS_UNUSED)
|
||||
->sum('balance');
|
||||
$query = UserBill::field('link_id,create_time,number coupon_price,mark,extra,status')
|
||||
->where('uid', $userId)
|
||||
->where('category', 'red_pack')
|
||||
->where('status', 1)
|
||||
->whereRaw("extra->'$.coupon_id'=" . $couponId);
|
||||
$count = $query->count();
|
||||
$record = $query->page($page)->limit($limit)->select()->toArray();
|
||||
foreach ($record as &$item) {
|
||||
$item['order_amount'] = 0;
|
||||
if (mb_strpos($item['mark'], '订单金额:') !== false) {
|
||||
$item['order_amount'] = mb_substr($item['mark'], mb_strpos($item['mark'], '订单金额:') + 5);
|
||||
}
|
||||
$item['extra'] = json_decode($item['extra'], true);
|
||||
unset($item['mark']);
|
||||
}
|
||||
$result = ['total_amount' => $totalAmount, 'count' => $count, 'record' => $record];
|
||||
return app('json')->success($result);
|
||||
}
|
||||
|
||||
}
|
@ -80,11 +80,7 @@ class StoreOrder extends BaseController
|
||||
$where['order_search'] = $this->request->param('search_info');
|
||||
$where['mer_id'] = $merId;
|
||||
$where['is_del'] = 0;
|
||||
$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);
|
||||
return app('json')->success($repository->merchantGetList($where, $page, $limit));
|
||||
}
|
||||
|
||||
public function order($merId, $id, StoreOrderRepository $repository)
|
||||
@ -94,7 +90,6 @@ 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());
|
||||
}
|
||||
|
||||
@ -416,8 +411,8 @@ class StoreOrder extends BaseController
|
||||
*/
|
||||
public function getOrderAutoMarginList($merId){
|
||||
[$page, $limit] = $this->getPage();
|
||||
$select= Db::name('financial_record')->where('mer_id',$merId)
|
||||
->where('financial_type','auto_margin')
|
||||
$select= Db::name('financial_record')->where('mer_id',$merId)->where('type',1)
|
||||
->where('financial_type','auto_margin')->where('financial_pm',0)
|
||||
->page($page)->limit($limit)->order('financial_record_id','desc')->select();
|
||||
return app('json')->success($select);
|
||||
|
||||
|
@ -133,22 +133,4 @@ 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);
|
||||
}
|
||||
|
||||
}
|
@ -128,10 +128,9 @@ class Merchant extends BaseController
|
||||
*/
|
||||
public function categoryList($id)
|
||||
{
|
||||
$pid = $this->request->get('pid', 0);
|
||||
if (!$this->repository->merExists((int)$id))
|
||||
return app('json')->fail('店铺已打烊');
|
||||
return app('json')->success($this->repository->categoryList($id, $pid));
|
||||
return app('json')->success($this->repository->categoryList($id));
|
||||
}
|
||||
|
||||
public function qrcode($id)
|
||||
@ -301,11 +300,10 @@ class Merchant extends BaseController
|
||||
if (empty($merchantInfo)) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
$merchantInfo['paid_margin'] = $merchantInfo['paid_margin'] > $merchantInfo['margin'] ? $merchantInfo['margin'] : $merchantInfo['paid_margin'];
|
||||
$merchantInfo['unpaid_margin'] = bcsub($merchantInfo['margin'], $merchantInfo['paid_margin'], 2);
|
||||
if ($merchantInfo['margin'] <= 0) {
|
||||
$merchantInfo['unpaid_margin'] = 0;
|
||||
$merchantInfo['paid_margin'] = 0;
|
||||
$margin = Db::name('MerchantType')->where('mer_type_id', $merchantInfo['type_id'])->value('margin');
|
||||
$merchantInfo['unpaid_margin'] = bcsub($margin, $merchantInfo['paid_margin'], 2);
|
||||
if ($merchantInfo['margin'] == 0) {
|
||||
$merchantInfo['margin'] = $merchantInfo['unpaid_margin'];
|
||||
}
|
||||
return app('json')->success($merchantInfo);
|
||||
}
|
||||
|
@ -80,6 +80,32 @@ class MerchantIntention extends BaseController
|
||||
'id' => $intention->mer_intention_id
|
||||
]
|
||||
]);
|
||||
$areaInfo = Db::name('geo_area')->where('area_code', $data['area_id'] ?? '')->find();
|
||||
$sendData = [
|
||||
'type' => 1,
|
||||
'type_name' => Db::name('merchant_type')->where('mer_type_id', $data['mer_type_id'])->value('type_name', ''),
|
||||
'category_name' => Db::name('merchant_category')->where('merchant_category_id', $data['merchant_category_id'])->value('category_name', ''),
|
||||
'mer_name' => $data['mer_name'] ?? '',
|
||||
'company_name' => $data['company_name'] ?? '',
|
||||
'organization_code' => $data['social_credit_code'] ?? '',
|
||||
'master_name' => $data['name'],
|
||||
'master_phone' => $data['phone'],
|
||||
'images' => !empty($data['images']) ? json_encode($data['images']) : '',
|
||||
'city' => $areaInfo['city_code'] ?? '',
|
||||
'area' => $data['area_id'] ?? '',
|
||||
'street' => $data['street_id'] ?? '',
|
||||
'village' => $data['village_id'] ?? '',
|
||||
'address' => $data['address'] ?? '',
|
||||
'mer_intention_id' => $intention->mer_intention_id,
|
||||
'type_id'=>$data['mer_type_id']??'',
|
||||
'is_company'=>$data['is_company']??'',
|
||||
];
|
||||
$postUrl = env('TASK_WORKER_HOST_URL') . '/adminapi/company/createShopMerchant';
|
||||
$res = $this->sendMerIntentionApply($sendData, $postUrl);
|
||||
if (!$res['ok']) {
|
||||
Db::name('merchant_intention')->where('mer_intention_id', $intention->mer_intention_id)->delete();
|
||||
throw new ValidateException('供销平台申请商户入驻失败,' . $res['msg']);
|
||||
}
|
||||
return app('json')->success('提交成功');
|
||||
}
|
||||
|
||||
@ -101,12 +127,8 @@ class MerchantIntention extends BaseController
|
||||
'street_id',
|
||||
'village_id',
|
||||
'is_nmsc',
|
||||
'is_company',
|
||||
'financial_bank'
|
||||
'is_company'
|
||||
]);
|
||||
if (!empty($data['financial_bank'])) {
|
||||
$data['financial_bank'] = json_encode($data['financial_bank']);
|
||||
}
|
||||
if (!systemConfig('mer_intention_open')) {
|
||||
return app('json')->fail('未开启商户入驻');
|
||||
}
|
||||
@ -188,34 +210,29 @@ class MerchantIntention extends BaseController
|
||||
return app('json')->fail('未开启商户入驻');
|
||||
}
|
||||
if ($this->userInfo) $data['uid'] = $this->userInfo->uid;
|
||||
$settleIn = $this->repository->getWhere(['type' => 1, 'uid' => $data['uid'], 'is_del' => 0]);
|
||||
$merchant = Merchant::where('uid', $data['uid'])->where('is_del', 0)->find();
|
||||
if (empty($settleIn) && empty($merchant)) {
|
||||
$merInfo = Db::name('merchant')->where('uid', $this->userInfo->uid)->where('status', 1)->find();
|
||||
if (empty($merInfo)) {
|
||||
return app('json')->fail('请申请商户入驻申请!');
|
||||
}
|
||||
if (!empty($settleIn) && $settleIn['status'] == 0) {
|
||||
return app('json')->fail('请等待商户入驻申请审核!');
|
||||
}
|
||||
$merIntentionInfo = $this->repository->getWhere(['type' => 2, 'uid' => $data['uid'], 'is_del' => 0]);
|
||||
if (!empty($merIntentionInfo) && ($merIntentionInfo['status'] == 0)) {
|
||||
if (!empty($merInfo['business_status']) && ($merInfo['business_status'] == 1)) {
|
||||
return app('json')->fail('商户交易已申请,正在审核中!');
|
||||
}
|
||||
if (!empty($merIntentionInfo) && ($merIntentionInfo['status'] == 1)) {
|
||||
if (!empty($merInfo['business_status']) && ($merInfo['business_status'] == 2)) {
|
||||
return app('json')->fail('商户交易申请已通过');
|
||||
}
|
||||
$intenInfo['phone'] = $merchant['mer_phone'];
|
||||
$intenInfo['mer_name'] = $merchant['mer_name'];
|
||||
$intenInfo['company_name'] = $merchant['mer_name'];
|
||||
$intenInfo['name'] = $merchant['real_name'];
|
||||
$intenInfo['social_credit_code'] = '';
|
||||
$intenInfo['images'] = [];
|
||||
$intenInfo['merchant_category_id'] = $merchant['category_id'];
|
||||
$intenInfo['mer_type_id'] = $merchant['type_id'];
|
||||
$intenInfo['area_id'] = $merchant['area_id'];
|
||||
$intenInfo['street_id'] = $merchant['street_id'];
|
||||
$intenInfo['village_id'] = $merchant['village_id'];
|
||||
$intenInfo['is_nmsc'] = $merchant['is_nmsc'];
|
||||
$intenInfo['address'] = $merchant['mer_address'];
|
||||
$intenInfo = Db::name('merchant_intention')->where('mer_intention_id', $merInfo['mer_intention_id'] ?? 0)->where('type', 1)->find();
|
||||
if (empty($intenInfo)) {
|
||||
// 兼容处理已开通商户
|
||||
$intenInfo = [
|
||||
'uid' => $merInfo['uid'],
|
||||
'mer_id' => $merInfo['mer_id'],
|
||||
'phone' => $merInfo['mer_phone'],
|
||||
'mer_name' => $merInfo['mer_name'],
|
||||
'name' => $merInfo['mer_name'],
|
||||
'merchant_category_id' => $merInfo['category_id'],
|
||||
'mer_type_id' => $merInfo['type_id'],
|
||||
];
|
||||
}
|
||||
$intenInfo['bank_username'] = $data['bank_username'];
|
||||
$intenInfo['bank_opening'] = $data['bank_opening'];
|
||||
$intenInfo['bank_code'] = $data['bank_code'];
|
||||
@ -223,11 +240,49 @@ class MerchantIntention extends BaseController
|
||||
$intenInfo['bank_back'] = $data['bank_back'];
|
||||
$intenInfo['cardno_front'] = $data['cardno_front'];
|
||||
$intenInfo['cardno_back'] = $data['cardno_back'];
|
||||
$intenInfo['uid'] = $data['uid'];
|
||||
|
||||
$intenInfo['type'] = 2;
|
||||
$intenInfo['status'] = 0;
|
||||
$intenInfo['create_time'] = date('Y-m-d H:i:s');
|
||||
$this->repository->create($intenInfo);
|
||||
|
||||
unset($intenInfo['mer_intention_id']);
|
||||
|
||||
$intentionId = Db::name('merchant_intention')->insertGetId($intenInfo);
|
||||
$areaInfo = Db::name('geo_area')->where('area_code', $intenInfo['area_id'] ?? '')->find();
|
||||
$sendData = [
|
||||
'type' => 2,
|
||||
'type_name' => Db::name('merchant_type')->where('mer_type_id', $merInfo['type_id'])->value('type_name', ''),
|
||||
'category_name' => Db::name('merchant_category')->where('merchant_category_id', $merInfo['category_id'])->value('category_name', ''),
|
||||
'mer_name' => $intenInfo['mer_name'] ?? '',
|
||||
'company_name' => $intenInfo['company_name'] ?? '',
|
||||
'organization_code' => $intenInfo['social_credit_code'] ?? '',
|
||||
'master_name' => $intenInfo['name'],
|
||||
'master_phone' => $intenInfo['phone'],
|
||||
'images' => !empty($intenInfo['images']) ? json_encode(explode(',', $intenInfo['images'])) : '',
|
||||
'city' => $areaInfo['city_code'] ?? '',
|
||||
'area' => $merInfo['area_id'] ?? '',
|
||||
'street' => $merInfo['street_id'] ?? '',
|
||||
'village' => $data['village_id'] ?? '',
|
||||
'address' => $intenInfo['address'] ?? '',
|
||||
'bank_username' => $data['bank_username'] ?? '',
|
||||
'bank_opening' => $data['bank_opening'] ?? '',
|
||||
'bank_code' => $data['bank_code'] ?? '',
|
||||
'bank_front' => $data['bank_front'] ?? '',
|
||||
'bank_back' => $data['bank_back'] ?? '',
|
||||
'cardno_front' => $data['cardno_front'] ?? '',
|
||||
'cardno_back' => $data['cardno_back'] ?? '',
|
||||
'mer_intention_id' => $intentionId,
|
||||
'type_id'=>$merInfo['type_id']??'',
|
||||
'is_company'=>$intenInfo['is_company']??'',
|
||||
|
||||
];
|
||||
$postUrl = env('TASK_WORKER_HOST_URL') . '/adminapi/company/createShopMerchant';
|
||||
$res = $this->sendMerIntentionApply($sendData, $postUrl);
|
||||
if (!$res['ok']) {
|
||||
Db::name('merchant_intention')->where('mer_intention_id', $intentionId)->delete();
|
||||
throw new ValidateException('供销平台商户交易申请失败,' . $res['msg']);
|
||||
}
|
||||
Db::name('merchant')->where('uid', $this->userInfo->uid)->where('status', 1)->update(['business_status' => 1]);
|
||||
return app('json')->success('申请成功');
|
||||
}
|
||||
|
||||
@ -298,6 +353,32 @@ class MerchantIntention extends BaseController
|
||||
'id' => $id
|
||||
]
|
||||
]);
|
||||
$areaInfo = Db::name('geo_area')->where('area_code', $data['area_id'] ?? '')->find();
|
||||
$sendData = [
|
||||
'type' => 1,
|
||||
'type_name' => Db::name('merchant_type')->where('mer_type_id', $data['mer_type_id'])->value('type_name', ''),
|
||||
'category_name' => Db::name('merchant_category')->where('merchant_category_id', $data['merchant_category_id'])->value('category_name', ''),
|
||||
'mer_name' => $data['mer_name'] ?? '',
|
||||
'company_name' => $data['company_name'] ?? '',
|
||||
'organization_code' => $data['social_credit_code'] ?? '',
|
||||
'master_name' => $data['name'],
|
||||
'master_phone' => $data['phone'],
|
||||
'images' => !empty($data['images']) ? json_encode($data['images']) : '',
|
||||
'city' => $areaInfo['city_code'] ?? '',
|
||||
'area' => $data['area_id'] ?? '',
|
||||
'street' => $data['street_id'] ?? '',
|
||||
'village' => $data['village_id'] ?? '',
|
||||
'address' => $data['address'] ?? '',
|
||||
'mer_intention_id' => $id,
|
||||
'type_id'=>$data['mer_type_id']??'',
|
||||
'is_company'=>$data['is_company']??'',
|
||||
|
||||
];
|
||||
$postUrl = env('TASK_WORKER_HOST_URL') . '/adminapi/company/createShopMerchant';
|
||||
$res = $this->sendMerIntentionApply($sendData, $postUrl);
|
||||
if (!$res['ok']) {
|
||||
throw new ValidateException('供销平台申请商户入驻失败,' . $res['msg']);
|
||||
}
|
||||
if($updateIntention){
|
||||
return app('json')->success('修改成功');
|
||||
}else{
|
||||
@ -341,20 +422,9 @@ class MerchantIntention extends BaseController
|
||||
'street_id',
|
||||
'village_id',
|
||||
'is_nmsc',
|
||||
'is_company',
|
||||
'bank_username',
|
||||
'bank_code',
|
||||
'bank_opening',
|
||||
'bank_front',
|
||||
'bank_back',
|
||||
'cardno_front',
|
||||
'cardno_back',
|
||||
'financial_bank',
|
||||
'is_company'
|
||||
]);
|
||||
|
||||
if (!empty($data['financial_bank'])) {
|
||||
$data['financial_bank'] = json_encode($data['financial_bank']);
|
||||
}
|
||||
app()->make(MerchantIntentionValidate::class)->check($data);
|
||||
$check = app()->make(SmsService::class)->checkSmsCode($data['phone'], $data['code'], 'intention');
|
||||
$data['mer_type_id'] = (int)$data['mer_type_id'];
|
||||
|
@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller\api\store\order;
|
||||
|
||||
use app\common\model\store\product\Product;
|
||||
use app\common\repositories\store\product\ProductRepository;
|
||||
use app\controller\api\Common;
|
||||
use crmeb\basic\BaseController;
|
||||
|
||||
/**
|
||||
* Class ScanPay
|
||||
* @package app\controller\api\store\ScanPay
|
||||
*/
|
||||
class ScanPay extends BaseController
|
||||
{
|
||||
|
||||
public function product()
|
||||
{
|
||||
$merId = $this->request->get('mer_id');
|
||||
$cateId = env('PICKUP_CARD_CATE_ID');
|
||||
$product = Product::where('mer_id', $merId)->where('cate_id', $cateId)->find();
|
||||
if (empty($product)) {
|
||||
return app('json')->fail('商品已下架');
|
||||
}
|
||||
$param = $this->request->params(['type', ['product_type', 0]]);
|
||||
/** @var ProductRepository $productRepo */
|
||||
$productRepo = app()->make(ProductRepository::class);
|
||||
$productRepo->force = true;
|
||||
$data = $productRepo->detail((int)$product['product_id'], $this->request->userInfo, $param['product_type']);
|
||||
if (!$data) {
|
||||
return app('json')->fail('商品已下架');
|
||||
}
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
public function qrcode()
|
||||
{
|
||||
$merId = $this->request->get('mer_id');
|
||||
/** @var Common $common */
|
||||
$common = app()->make(Common::class);
|
||||
$siteUrl = systemConfig('site_url');
|
||||
$user = $this->request->userInfo();
|
||||
$data = $common->Qrcode(['code' => $siteUrl . 'pages/payment/get_payment?mer_id=' . $merId, 'id' => $user['uid']]);
|
||||
return app('json')->success(['url' => $data]);
|
||||
}
|
||||
|
||||
}
|
@ -31,7 +31,6 @@ use crmeb\basic\BaseController;
|
||||
use app\validate\api\StoreCartValidate as validate;
|
||||
use app\common\repositories\store\order\StoreCartRepository as repository;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Cache;
|
||||
use think\facade\Log;
|
||||
|
||||
class StoreCart extends BaseController
|
||||
@ -143,9 +142,6 @@ class StoreCart extends BaseController
|
||||
}
|
||||
$cart = $storeCart = $this->repository->create($data);
|
||||
}
|
||||
if (isset($data['total_amount'])) {
|
||||
Cache::set('cart_id_' . $cart['cart_id'], $data['total_amount'], 600);
|
||||
}
|
||||
event('user.cart', compact('user','storeCart'));
|
||||
return app('json')->success(['cart_id' => $cart['cart_id']]);
|
||||
}
|
||||
@ -259,7 +255,7 @@ class StoreCart extends BaseController
|
||||
*/
|
||||
public function checkParams(validate $validate)
|
||||
{
|
||||
$data = $this->request->params(['product_id','product_attr_unique','cart_num','is_new',['product_type',0],['group_buying_id',0],['spread_id',0], 'referer',['source',2], 'total_amount']);
|
||||
$data = $this->request->params(['product_id','product_attr_unique','cart_num','is_new',['product_type',0],['group_buying_id',0],['spread_id',0], 'referer',['source',2]]);
|
||||
$validate->check($data);
|
||||
if ($data['spread_id']) {
|
||||
if ($data['spread_id'] !== $this->request->userInfo()->uid){
|
||||
|
@ -301,23 +301,4 @@ class StoreOrderOther extends BaseController
|
||||
return app('json')->fail('操作失败');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*上传付款凭证
|
||||
*/
|
||||
|
||||
public function upload($id)
|
||||
{
|
||||
$name = $this->request->param('url');
|
||||
Db::transaction(function()use($id,$name){
|
||||
$make = \app()->make(\app\common\model\store\order\StoreOrderOther::class);
|
||||
$make->chageVoucher($id,$name);
|
||||
});
|
||||
return app('json')->success('更新成功');
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,98 +2,60 @@
|
||||
|
||||
namespace app\controller\api\store\order;
|
||||
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use think\facade\Db;
|
||||
use crmeb\basic\BaseController;
|
||||
use think\facade\Log;
|
||||
use app\common\repositories\system\merchant\FinancialRecordRepository;
|
||||
|
||||
/**
|
||||
* 订单处理
|
||||
*/
|
||||
class StoreProcessing extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 自动向市级供应链创建订单
|
||||
* @param $order
|
||||
* @return void
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function AutomaticallyCreateOrders($order)
|
||||
{
|
||||
if (!in_array($order['source'], [103, 105])) {
|
||||
return;
|
||||
}
|
||||
$orderUser = Db::name('merchant')->where('mer_id', $order['mer_id'])->find();
|
||||
|
||||
|
||||
$merchant_two = Db::name('merchant')->where('mer_id', $order['mer_id'])->find();
|
||||
$store_group_order = Db::name('store_group_order')->where('group_order_id', $order['group_order_id'])->find();
|
||||
$store_group_order_other = Db::name('store_group_order_other')->where('group_order_sn', $store_group_order['group_order_sn'])->find();
|
||||
$store_group_order_other = Db::name('store_group_order_other')->where('group_order_sn', $order['order_sn'])->find();
|
||||
if (!$store_group_order_other) {
|
||||
unset($store_group_order['group_order_id']);
|
||||
$group_order_id = Db::name('store_group_order_other')->strict(false)->insertGetId($store_group_order);
|
||||
} else {
|
||||
$group_order_id = $store_group_order_other['group_order_id'];
|
||||
}else{
|
||||
$group_order_id=$store_group_order_other['group_order_id'];
|
||||
}
|
||||
$orderProducts = Db::name('store_order_product')->where('order_id', $order['order_id'])->select()->toArray();
|
||||
$merchants = [];
|
||||
foreach ($orderProducts as $item) {
|
||||
$cartInfo = json_decode($item['cart_info'], true);
|
||||
$payPrice = bcmul($cartInfo['productAttr']['procure_price'], $item['product_num'], 2);
|
||||
if (isset($merchants[$item['product_mer_id']])) {
|
||||
$merchants[$item['product_mer_id']]['total_price'] = bcadd($merchants[$item['product_mer_id']]['total_price'], $payPrice, 2);
|
||||
$merchants[$item['product_mer_id']]['total_num'] = $merchants[$item['product_mer_id']]['total_num'] + $item['product_num'];
|
||||
} else {
|
||||
$merchants[$item['product_mer_id']]['total_price'] = $payPrice;
|
||||
$merchants[$item['product_mer_id']]['total_num'] = $item['product_num'];
|
||||
}
|
||||
$merchants[$item['product_mer_id']]['product'][] = $item;
|
||||
}
|
||||
$productOther = [];
|
||||
foreach ($merchants as $merId => $merchant) {
|
||||
$select = Db::name('store_order_product')->where('order_id', $order['order_id'])->select();
|
||||
if ($order['source'] == 103 ||$order['source'] == 105 && $select) {
|
||||
// $financialRecordRepository = app()->make(FinancialRecordRepository::class);
|
||||
// $financeSn = $financialRecordRepository->getSn();
|
||||
$arr = $select->toArray();
|
||||
$order['group_order_id'] = $group_order_id;
|
||||
$order['source'] = 104;
|
||||
$order['mer_id'] = $merId;
|
||||
$order['uid'] = $orderUser['uid'];
|
||||
$order['real_name'] = $orderUser['mer_name'] . '-' . $orderUser['real_name'];
|
||||
$order['user_phone'] = $orderUser['mer_phone'];
|
||||
$order['user_address'] = $orderUser['mer_address'];
|
||||
|
||||
$order['mer_id'] = $select[0]['product_mer_id'];
|
||||
$order['uid'] = $merchant_two['uid'];
|
||||
$order['real_name'] = $merchant_two['mer_name'] . '-' . $merchant_two['real_name'];
|
||||
$order['user_phone'] = $merchant_two['mer_phone'];
|
||||
$order['user_address'] = $merchant_two['mer_address'];
|
||||
$order['order_type'] = 0;
|
||||
$order['pay_price'] = $merchant['total_price'];
|
||||
$order['total_price'] = $merchant['total_price'];
|
||||
$order['procure_price'] = $merchant['total_price'];
|
||||
$order['total_num'] = $merchant['total_num'];
|
||||
|
||||
unset($order['order_id'], $order['orderProduct'], $order['user'], $order['supply_chain_rate'], $order['logistics_code'], $order['logistics_phone']);
|
||||
$orderId = Db::name('store_order_other')->strict(false)->insertGetId($order);
|
||||
$productOther = array_merge($productOther, $this->setOrderOtherProduct($merchant, $orderUser, $orderId));
|
||||
}
|
||||
Db::name('store_order_product_other')->strict(false)->insertAll($productOther);
|
||||
}
|
||||
$order_id = Db::name('store_order_other')->strict(false)->insertGetId($order);
|
||||
|
||||
/**
|
||||
* 设置订单商品
|
||||
* @param $merchant
|
||||
* @param $orderUser
|
||||
* @param $orderId
|
||||
* @return array
|
||||
*/
|
||||
public function setOrderOtherProduct($merchant, $orderUser, $orderId)
|
||||
{
|
||||
$productOther = [];
|
||||
foreach ($merchant['product'] as $product) {
|
||||
$cartInfo = json_decode($product['cart_info'], true);
|
||||
$product['order_id'] = $orderId;
|
||||
$product['source'] = 104;
|
||||
$product['product_price'] = bcmul($cartInfo['productAttr']['procure_price'], $product['product_num'], 2);
|
||||
$product['total_price'] = $product['product_price'];
|
||||
$product['pay_price'] = $product['product_price'];
|
||||
$product['product_id'] = $product['product_source_id'];
|
||||
$product['uid'] = $orderUser['uid'];
|
||||
$product['product_source_id'] = 0;
|
||||
$product['product_mer_id'] = 0;
|
||||
unset($product['order_product_id']);
|
||||
$productOther[] = $product;
|
||||
Db::name('store_product')->where('product_id', $product['product_source_id'])->dec('stock');
|
||||
foreach ($arr as $key => $value) {
|
||||
$arr[$key]['order_id'] = $order_id;
|
||||
$arr[$key]['source'] = 104;
|
||||
unset($arr[$key]['order_product_id']);
|
||||
Db::name('store_product')->where('product_id',$value['product_id'])->dec('stock');
|
||||
}
|
||||
// $financialRecordRepository->insertAll($finance);
|
||||
Db::name('store_order_product_other')->strict(false)->insertAll($arr);
|
||||
return $order_id;
|
||||
}
|
||||
return $productOther;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class StoreProductPresell extends BaseController
|
||||
public function lst()
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$where = $this->request->params([['type',4],'star','mer_id', 'keyword']);
|
||||
$where = $this->request->params([['type',4],'star','mer_id']);
|
||||
return app('json')->success($this->repository->getApiList($where,$page, $limit));
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@ namespace app\controller\api\store\product;
|
||||
|
||||
use app\common\dao\store\CityAreaDao;
|
||||
use app\common\dao\system\merchant\MerchantDao;
|
||||
use app\common\model\store\product\ProductLabel;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\repositories\store\StoreCategoryRepository;
|
||||
use app\common\repositories\system\merchant\MerchantRepository;
|
||||
@ -65,20 +64,12 @@ class StoreSpu extends BaseController
|
||||
'category_id',
|
||||
'type_code',
|
||||
'village_id',
|
||||
'location',
|
||||
'sys_labels',
|
||||
'deduction_rate'
|
||||
'location'
|
||||
]);
|
||||
// if (isset($where['type_code']) && $where['type_code'] == 'PersonalStore') {
|
||||
// $where['long'] = '';
|
||||
// $where['lat'] = '';
|
||||
// $where['type_id'] = 21;
|
||||
// } else {
|
||||
// [$lat, $lng] = (new CityAreaDao())->getLngAndLat($where['location'], $where['street_id']);
|
||||
// $where['long'] = $lng;
|
||||
// $where['lat'] = $lat;
|
||||
// }
|
||||
if ($where['type_id'] || $where['type_code']) {
|
||||
[$lat, $lng] = (new CityAreaDao())->getLngAndLat($where['location'], $where['street_id']);
|
||||
$where['long']=$lng;
|
||||
$where['lat']=$lat;
|
||||
if ($where['type_id']||$where['type_code']) {
|
||||
$arr = ['status' => 1, 'mer_state' => 1, 'is_del' => 0];
|
||||
$query = Merchant::where($arr);
|
||||
// $merIds = (new MerchantDao())->getValidMerchantByDistance($lat, $lng);
|
||||
@ -94,25 +85,19 @@ class StoreSpu extends BaseController
|
||||
// $query->where('type_id', $mer_type_id);
|
||||
// }
|
||||
// }
|
||||
$mer_type_id = Db::name('merchant_type')->where('type_code', $where['type_code'])->value('mer_type_id');
|
||||
if ($mer_type_id && $where['type_code'] == 'PersonalStore') {
|
||||
$where['mer_ids'] = $query->where('type_id', $mer_type_id)->column('mer_id');
|
||||
}else{
|
||||
$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']);
|
||||
unset($where['type_id'], $where['street_id'],$where['type_code'],$where['village_id']);
|
||||
|
||||
$where['is_gift_bag'] = 0;
|
||||
$where['product_type'] = $where['product_type'] != '' ? $where['product_type'] : 0;
|
||||
$where['order'] = $where['order'] ?: 'star';
|
||||
if ($where['is_trader'] != 1) unset($where['is_trader']);
|
||||
if ($where['category_id'] != '') {
|
||||
$where['mer_ids'] = Db::name('merchant')->where(['category_id' => $where['category_id'], 'status' => 1, 'is_del' => 0])->column('mer_id');
|
||||
if($where['category_id']!=''){
|
||||
$where['mer_ids']= Db::name('merchant')->where(['category_id'=>$where['category_id'],'status'=>1,'is_del'=>0])->column('mer_id');
|
||||
}
|
||||
$data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo, true);
|
||||
$data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
@ -164,13 +149,13 @@ class StoreSpu extends BaseController
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$where = $this->request->params([
|
||||
'keyword', 'cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid', 'mer_cate_id', ['product_type', 0], 'action', 'common', 'deduction_rate'
|
||||
'keyword', 'cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid', 'mer_cate_id', ['product_type', 0], 'action', 'common'
|
||||
]);
|
||||
if ($where['action']) unset($where['product_type']);
|
||||
$where['mer_id'] = $id;
|
||||
$where['is_gift_bag'] = 0;
|
||||
$where['order'] = $where['order'] ? $where['order'] : 'sort';
|
||||
$data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo, true);
|
||||
$data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo,true);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
@ -419,12 +404,4 @@ class StoreSpu extends BaseController
|
||||
}
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
public function storeLabel()
|
||||
{
|
||||
$merId = $this->request->get('mer_id');
|
||||
$list = ProductLabel::where('mer_id', $merId)->select()->toArray();
|
||||
return app('json')->success($list);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,13 +10,11 @@
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\controller\api\user;
|
||||
|
||||
use app\common\dao\store\order\StoreOrderDao;
|
||||
use app\common\model\store\order\StoreOrderOther;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
|
||||
use app\common\repositories\store\IntegralRepository;
|
||||
use app\common\repositories\store\order\PresellOrderRepository;
|
||||
use app\common\repositories\store\service\StoreServiceRepository;
|
||||
use app\common\repositories\system\CacheRepository;
|
||||
use app\common\repositories\user\MemberinterestsRepository;
|
||||
@ -33,7 +31,6 @@ use think\db\exception\DataNotFoundException;
|
||||
use think\db\exception\DbException;
|
||||
use think\db\exception\ModelNotFoundException;
|
||||
use app\controller\api\Common;
|
||||
use app\common\model\user\User as UserModel;
|
||||
|
||||
class User extends BaseController
|
||||
{
|
||||
@ -96,7 +93,6 @@ class User extends BaseController
|
||||
'now_money' => $user->now_money,
|
||||
'broken_day' => (int)systemConfig('lock_brokerage_timer'),
|
||||
'user_extract_min' => (int)systemConfig('user_extract_min'),
|
||||
'mer_extract_min' => (int)systemConfig('extract_minimum_num'),
|
||||
];
|
||||
return app('json')->success($data);
|
||||
}
|
||||
@ -544,43 +540,9 @@ class User extends BaseController
|
||||
* 生成二维码
|
||||
*/
|
||||
public function qrcode(){
|
||||
if ($this->user->is_promoter != 1) {
|
||||
return app('json')->fail('您不是推广员');
|
||||
}
|
||||
$common= app()->make(Common::class);
|
||||
$siteUrl = systemConfig('site_url');
|
||||
$data=$common->Qrcode(['code'=>$siteUrl.'download/index.html?code=shop_'.$this->user->uid,'id'=>$this->user->uid]);
|
||||
return app('json')->success(['url'=>$data]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 邀请的商户记录
|
||||
* @return mixed
|
||||
* @throws DataNotFoundException
|
||||
* @throws DbException
|
||||
* @throws ModelNotFoundException
|
||||
*/
|
||||
public function merchantRecord()
|
||||
{
|
||||
[$page, $limit] = $this->getPage();
|
||||
$userQuery = UserModel::where('spread_uid', $this->user->uid);
|
||||
$count = $userQuery->count();
|
||||
$userIds = $userQuery->page($page, $limit)->column('uid');
|
||||
$query = Merchant::whereIn('uid', $userIds)->where('is_del', 0);
|
||||
$merchants = $query->field('mer_id,mer_name,uid,real_name,sale_amount,purchase_amount as buy_amount')
|
||||
->select()->toArray();
|
||||
$merchants = reset_index($merchants, 'uid');
|
||||
$result = [];
|
||||
foreach ($userIds as $userId) {
|
||||
if (isset($merchants[$userId])) {
|
||||
$merchant = $merchants[$userId];
|
||||
$merchant['status'] = 1;
|
||||
$result[] = $merchant;
|
||||
} else {
|
||||
$result[] = ['mer_id' => '', 'mer_name' => '', 'uid' => $userId, 'real_name' => '', 'sale_amount' => '0.00', 'buy_amount' => '0.00', 'status' => 0];
|
||||
}
|
||||
}
|
||||
return app('json')->success(['count' => $count, 'list' => $result]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class OrderOther extends BaseController
|
||||
}
|
||||
$where['paid']=1;
|
||||
if($where['source']<=0){
|
||||
$where['source']=12;
|
||||
$where['source']=105;
|
||||
}
|
||||
return app('json')->success($this->repository->merchantGetList($where, $page, $limit));
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class ProductLabel extends BaseController
|
||||
|
||||
public function checkParams(ProductLabelValidate $validate)
|
||||
{
|
||||
$params = ['label_name', 'status', 'sort', 'info', 'value'];
|
||||
$params = ['label_name', 'status', 'sort', 'info'];
|
||||
$data = $this->request->params($params);
|
||||
$validate->check($data);
|
||||
return $data;
|
||||
|
@ -56,9 +56,6 @@ return [
|
||||
\crmeb\listens\CloseUserSvipListen::class,
|
||||
\crmeb\listens\SendSvipCouponListen::class,
|
||||
\crmeb\listens\AutoCheckCreditBuyListen::class,
|
||||
// \crmeb\listens\ActivateConsumptionListen::class,
|
||||
\crmeb\listens\SetProductProfitRateListen::class,
|
||||
\crmeb\listens\SendSubsidyCouponListen::class,
|
||||
] : [],
|
||||
'pay_success_user_recharge' => [\crmeb\listens\pay\UserRechargeSuccessListen::class],
|
||||
'pay_success_user_order' => [\crmeb\listens\pay\UserOrderSuccessListen::class],
|
||||
@ -80,7 +77,6 @@ return [
|
||||
'refund.deliver'=>[\app\listener\DeliverRefund::class],
|
||||
'order.create'=>[\app\listener\OrderCreate::class],
|
||||
'order.take'=>[\app\listener\OrderTake::class],
|
||||
'order.delivery' => [\crmeb\listens\OrderDeliveryListen::class], // 发货事件
|
||||
],
|
||||
|
||||
'subscribe' => [],
|
||||
|
@ -35,10 +35,10 @@ class paySuccess
|
||||
{
|
||||
try {
|
||||
$orderList = $event['groupOrder']['orderList'];
|
||||
// if ($event['groupOrder']['source'] == 103) {
|
||||
// $storeConsumptionUserDao = new StoreConsumptionUserDao();
|
||||
// $storeConsumptionUserDao->check($event['groupOrder']['uid'], $event['groupOrder']['group_order_id']);
|
||||
// }
|
||||
if ($event['groupOrder']['source'] == 103) {
|
||||
$storeConsumptionUserDao = new StoreConsumptionUserDao();
|
||||
$storeConsumptionUserDao->check($event['groupOrder']['uid'], $event['groupOrder']['group_order_id']);
|
||||
}
|
||||
foreach ($orderList as $k => $order) {
|
||||
//
|
||||
$StoreProcessing->AutomaticallyCreateOrders($order);
|
||||
|
@ -54,14 +54,14 @@
|
||||
"swoole/ide-helper": "^4.8",
|
||||
"alibabacloud/dysmsapi-20170525": "2.0.9",
|
||||
"vlucas/phpdotenv": "^5.3",
|
||||
"overtrue/pinyin": "4.1.0",
|
||||
"jpush/jpush": "^3.6",
|
||||
"guzzlehttp/guzzle": "^6.5",
|
||||
"topthink/think-api": "1.0.27",
|
||||
"intervention/image": "^2.7",
|
||||
"fastknife/ajcaptcha": "^1.2",
|
||||
"nelexa/zip": "^4.0",
|
||||
"alibabacloud/ocr-20191230": "^3.0",
|
||||
"overtrue/pinyin": "^4.1"
|
||||
"alibabacloud/ocr-20191230": "^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/var-dumper": "^4.2",
|
||||
|
6
composer.lock
generated
6
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "410f10b19a4e2c799d95f6050fd87e73",
|
||||
"content-hash": "58b44ebbb4f75dc8b47bcaa0ae8327f7",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adbario/php-dot-notation",
|
||||
@ -2635,7 +2635,7 @@
|
||||
"version": "4.1.0",
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://mirrors.tencent.com/repository/composer/overtrue/pinyin/4.1.0/overtrue-pinyin-4.1.0.zip",
|
||||
"url": "https://mirrors.cloud.tencent.com/repository/composer/overtrue/pinyin/4.1.0/overtrue-pinyin-4.1.0.zip",
|
||||
"reference": "4d0fb4f27f0c79e81c9489e0c0ae4a4f8837eae7",
|
||||
"shasum": ""
|
||||
},
|
||||
@ -5305,5 +5305,5 @@
|
||||
"ext-swoole": "^4.4.0"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"plugin-api-version": "2.3.0"
|
||||
"plugin-api-version": "2.1.0"
|
||||
}
|
||||
|
@ -17,9 +17,9 @@ return [
|
||||
//默认上传模式
|
||||
'default' => 'local',
|
||||
//上传文件大小
|
||||
'filesize' => 102400000,
|
||||
'filesize' => 52428800,
|
||||
//上传文件后缀类型
|
||||
'fileExt' => ['jpg', 'jpeg', 'png', 'gif', 'pem', 'mp3', 'wma', 'wav', 'amr', 'mp4', 'key', 'xlsx', 'xls', 'ico', 'apk', 'ipa','wgt','zip','webp'],
|
||||
'fileExt' => ['jpg', 'jpeg', 'png', 'gif', 'pem', 'mp3', 'wma', 'wav', 'amr', 'mp4', 'key', 'xlsx', 'xls', 'ico', 'apk', 'ipa','wgt','zip'],
|
||||
//上传文件类型
|
||||
'fileMime' => ['image/jpeg', 'image/gif', 'image/png', 'text/plain', 'audio/mpeg', 'image/vnd.microsoft.icon','application/widget','application/zip'],
|
||||
//驱动模式
|
||||
|
@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace crmeb\listens;
|
||||
|
||||
use app\common\model\store\consumption\StoreConsumption;
|
||||
use app\common\model\store\consumption\StoreConsumptionUser;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\model\user\UserBill;
|
||||
use crmeb\interfaces\ListenerInterface;
|
||||
use crmeb\services\TimerService;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* 定时任务:激活商户补贴
|
||||
*/
|
||||
class ActivateConsumptionListen extends TimerService implements ListenerInterface
|
||||
{
|
||||
|
||||
public function handle($event): void
|
||||
{
|
||||
$this->tick(1000 * 60, function () {
|
||||
Log::info('定时任务:激活商户补贴');
|
||||
$count = 0;
|
||||
$couponId = StoreConsumption::where('type', StoreConsumption::TYPE_RECHARGE)->value('coupon_id');
|
||||
if (empty($couponId)) {
|
||||
return;
|
||||
}
|
||||
$buyCouponId = StoreConsumption::where('type', StoreConsumption::TYPE_PULL_CONSUMPTION)->value('coupon_id');
|
||||
$storeConsumptionUser = StoreConsumptionUser::where('coupon_id', $couponId)
|
||||
->where('status', StoreConsumptionUser::STATUS_REPEAL)
|
||||
->select();
|
||||
foreach ($storeConsumptionUser as $item) {
|
||||
$saleTotal = Merchant::where('uid', $item['uid'])->value('sale_amount');
|
||||
$balance = StoreConsumptionUser::where('coupon_id', $buyCouponId)->where('uid', $item['uid'])->value('balance');
|
||||
if ($saleTotal >= $item['order_amount'] && $balance <= 0) {
|
||||
$item->status = StoreConsumptionUser::STATUS_UNUSED;
|
||||
$item->start_time = date('Y-m-d H:i:s');
|
||||
$item->end_time = date('Y-m-d H:i:s', strtotime('+1 year'));
|
||||
$item->save();
|
||||
UserBill::where('link_id', $item['coupon_user_id'])->where('type', 'red_pack_2')->update(['status' => 1]);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
Log::info('定时任务:激活商户补贴,执行数量:' . $count);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -18,39 +18,24 @@ use app\common\repositories\user\UserBillRepository;
|
||||
use crmeb\interfaces\ListenerInterface;
|
||||
use crmeb\services\TimerService;
|
||||
use think\facade\Db;
|
||||
use think\facade\Log;
|
||||
|
||||
class AutoUnlockMerchantMoneyListen extends TimerService implements ListenerInterface
|
||||
{
|
||||
public function handle($event): void
|
||||
{
|
||||
$this->tick(1000 * 60 * 60, function () {
|
||||
if (time() >= strtotime('today 00:00:00') && time() <= strtotime('today 02:00:00')) {
|
||||
$this->tick(1000 * 60 * 20, function () {
|
||||
request()->clearCache();
|
||||
/** @var UserBillRepository $userBill */
|
||||
$userBill = app()->make(UserBillRepository::class);
|
||||
// $timer = ((int)systemConfig('mer_lock_time'));
|
||||
// $time = date('Y-m-d H:i:s', $timer ? strtotime("- $timer day") : time());
|
||||
$time = date('Y-m-d 00:00:00', strtotime('-1 day'));
|
||||
$timer = ((int)systemConfig('mer_lock_time'));
|
||||
$time = date('Y-m-d H:i:s', $timer ? strtotime("- $timer day") : time());
|
||||
$bills = $userBill->getTimeoutMerchantMoneyBill($time);
|
||||
$merchant = app()->make(MerchantRepository::class);
|
||||
$count = 0;
|
||||
foreach ($bills as $bill) {
|
||||
Db::startTrans();
|
||||
try {
|
||||
Db::transaction(function () use ($bill, $merchant) {
|
||||
$merchant->addMoney($bill->mer_id, $bill->number);
|
||||
$bill->status = 1;
|
||||
$bill->save();
|
||||
Db::commit();
|
||||
$count++;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
Log::error('商户冻结金额解冻出错:' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
if ($count > 0) {
|
||||
Log::info('商户冻结金额解冻成功:' . $count);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace crmeb\listens;
|
||||
|
||||
use app\common\dao\store\consumption\StoreConsumptionUserDao;
|
||||
use app\common\model\store\consumption\StoreConsumption;
|
||||
use app\common\model\store\consumption\StoreConsumptionUser;
|
||||
use crmeb\interfaces\ListenerInterface;
|
||||
|
||||
/**
|
||||
* Class OrderDeliveryListen
|
||||
*/
|
||||
class OrderDeliveryListen implements ListenerInterface
|
||||
{
|
||||
public function handle($event): void
|
||||
{
|
||||
$order = $event['order'];
|
||||
$consumptionTotal = 0;
|
||||
foreach ($order->orderProduct as $orderProduct) {
|
||||
if (!$orderProduct->product->isPlatformCard()) {
|
||||
continue;
|
||||
}
|
||||
$consumptionTotal = bcadd($consumptionTotal, $orderProduct->total_price, 2);
|
||||
}
|
||||
if ($consumptionTotal > 0) {
|
||||
$consumption = StoreConsumption::where('type', StoreConsumption::TYPE_PULL_CONSUMPTION)->find();
|
||||
/** @var StoreConsumptionUserDao $repo */
|
||||
$repo = app()->make(StoreConsumptionUserDao::class);
|
||||
$repo->startTime = date('Y-m-d H:i:s');
|
||||
$repo->endTime = '2025-07-01';
|
||||
$repo->send($consumption, 1, $order['uid'], $order['group_order_id'], $consumptionTotal, StoreConsumptionUser::STATUS_UNUSED);
|
||||
|
||||
$consumption = StoreConsumption::where('type', StoreConsumption::TYPE_RECHARGE)->find();
|
||||
$repo->startTime = date('Y-m-d H:i:s');
|
||||
$repo->endTime = '2025-07-01';
|
||||
$consumptionTotal = min($consumptionTotal, 100000);
|
||||
$rate = $this->getRate($consumptionTotal);
|
||||
$repo->send($consumption, $rate, $order['uid'], $order['group_order_id'], $consumptionTotal, StoreConsumptionUser::STATUS_REPEAL, StoreConsumptionUser::TYPE_TWO);
|
||||
}
|
||||
}
|
||||
|
||||
public function getRate($orderAmount)
|
||||
{
|
||||
if ($orderAmount >= 1000 && $orderAmount < 5000) {
|
||||
$rate = 0.05;
|
||||
} elseif ($orderAmount >= 5000 && $orderAmount < 10000) {
|
||||
$rate = 0.10;
|
||||
} elseif ($orderAmount >= 10000 && $orderAmount < 50000) {
|
||||
$rate = 0.15;
|
||||
} elseif ($orderAmount >= 50000) {
|
||||
$rate = 0.20;
|
||||
}
|
||||
return $rate ?? 0;
|
||||
}
|
||||
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace crmeb\listens;
|
||||
|
||||
use app\common\dao\store\consumption\StoreConsumptionUserDao;
|
||||
use app\common\model\store\consumption\StoreConsumption;
|
||||
use app\common\model\store\consumption\StoreConsumptionUser;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use crmeb\interfaces\ListenerInterface;
|
||||
use crmeb\services\TimerService;
|
||||
use think\facade\Log;
|
||||
|
||||
class SendSubsidyCouponListen extends TimerService implements ListenerInterface
|
||||
{
|
||||
|
||||
public function handle($event): void
|
||||
{
|
||||
//TODO 上线后改成30分钟
|
||||
$this->tick(1000 * 60 * 1, function () {
|
||||
Log::info('定时任务:发放商户采购补贴券');
|
||||
try {
|
||||
$consumption = StoreConsumption::where('type', StoreConsumption::TYPE_SALE_SUBSIDY)->find();
|
||||
$count = 0;
|
||||
if ($consumption) {
|
||||
foreach ($consumption['config'] as $item) {
|
||||
$purchaseAmount = $item['amount'] * 0.5;
|
||||
$merchants = Merchant::whereIn('type_id', $item['type_id'])
|
||||
->where('sale_amount', '>=', $item['amount'])
|
||||
->where('purchase_amount', '>=', $purchaseAmount)
|
||||
->select();
|
||||
foreach ($merchants as $merchant) {
|
||||
//商户已获得的补贴金额
|
||||
$gotSubsidy = StoreConsumptionUser::where('coupon_id', $consumption['coupon_id'])
|
||||
->where('uid', $merchant->uid)
|
||||
->value('coupon_price');
|
||||
if ($gotSubsidy >= $item['subsidy']) {
|
||||
continue;
|
||||
}
|
||||
//补贴金额为当前补贴减去已获得的补贴
|
||||
$amount = bcsub($item['subsidy'], $gotSubsidy, 2);
|
||||
$consumptionRepo = new StoreConsumptionUserDao();
|
||||
$consumptionRepo->billExtra = [
|
||||
'coupon_id' => $consumption['coupon_id'],
|
||||
'sale_amount' => $item['amount'],
|
||||
'purchase_amount' => $purchaseAmount,
|
||||
'status' => -1,
|
||||
];
|
||||
$consumptionRepo->onlyBill = true;
|
||||
$consumptionRepo->send($consumption, 1, $merchant->uid, 0, $amount, StoreConsumptionUser::STATUS_REPEAL, StoreConsumptionUser::TYPE_TWO);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Log::info('定时任务:发放商户采购补贴券,成功数量:' . $count);
|
||||
} catch (\Throwable $e) {
|
||||
Log::info('定时任务:发放商户采购补贴券,error => ' . $e->getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace crmeb\listens;
|
||||
|
||||
use app\common\model\store\product\ProductAttrValue;
|
||||
use crmeb\interfaces\ListenerInterface;
|
||||
use crmeb\services\TimerService;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* 定时任务:激活商户补贴
|
||||
*/
|
||||
class SetProductProfitRateListen extends TimerService implements ListenerInterface
|
||||
{
|
||||
|
||||
public function handle($event): void
|
||||
{
|
||||
$this->tick(1000 * 60, function () {
|
||||
Log::info('定时任务:更新商品利润率');
|
||||
try {
|
||||
$storeProducts = ProductAttrValue::where('profit_rate', 0)
|
||||
->where('procure_price', '>', 0)
|
||||
->whereRaw('price>procure_price')
|
||||
->limit(100)
|
||||
->select();
|
||||
foreach ($storeProducts as $storeProduct) {
|
||||
$profitRate = bcdiv(bcsub($storeProduct->price, $storeProduct->procure_price, 2), $storeProduct->price, 2) * 100;
|
||||
ProductAttrValue::where('unique', $storeProduct->unique)->update(['profit_rate' => $profitRate]);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::info('定时任务:更新商品利润率,error => ' . $e->getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -12,7 +12,6 @@
|
||||
|
||||
namespace crmeb\services;
|
||||
|
||||
use app\common\model\system\merchant\FinancialRecord;
|
||||
use app\common\repositories\store\order\StoreImportDeliveryRepository;
|
||||
use app\common\repositories\store\order\StoreOrderProfitsharingRepository;
|
||||
use app\common\repositories\store\order\StoreOrderRepository;
|
||||
@ -122,7 +121,7 @@ class ExcelService
|
||||
*/
|
||||
public function order(array $where, int $page, int $limit)
|
||||
{
|
||||
$paytype = [0 => '余额', 1 => '微信', 2 => '小程序', 3 => 'H5', 4 => '支付宝', 5 => '支付宝扫码', 6 => '微信扫码',8=>'信用购-先货后款',9=>'商户余额支付'];
|
||||
$paytype = [0 => '余额', 1 => '微信', 2 => '小程序', 3 => 'H5', 4 => '支付宝', 5 => '支付宝扫码', 6 => '微信扫码',];
|
||||
$make = app()->make(StoreOrderRepository::class);
|
||||
$status = $where['status'];
|
||||
$del = $where['mer_id'] > 0 ? 0 : null;
|
||||
@ -140,14 +139,12 @@ 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 = [
|
||||
@ -172,8 +169,6 @@ class ExcelService
|
||||
];
|
||||
$export[] = $one;
|
||||
}
|
||||
|
||||
|
||||
$header = ['商户名称', '订单编号', '订单类型', '推广人', '用户信息', '商品名称', '商品规格', '商品数量', '商品价格', '优惠', '实付邮费(元)', '实付金额(元)', '已退款金额(元)', '收货人', '收货人电话', '收货地址', '物流/电话', '下单时间', '支付方式', '支付状态', '商家备注'];
|
||||
$filename = '订单列表_' . date('YmdHis');
|
||||
$title = ['订单列表', '导出时间:' . date('Y-m-d H:i:s', time())];
|
||||
@ -318,7 +313,7 @@ class ExcelService
|
||||
}
|
||||
|
||||
/**
|
||||
* 平台/商户 导出日月账单信息
|
||||
* TODO 平台/商户 导出日月账单信息
|
||||
* @param array $where
|
||||
* @param int $id
|
||||
* @author Qinii
|
||||
@ -326,13 +321,62 @@ class ExcelService
|
||||
*/
|
||||
public function exportFinancial(array $where, int $page, int $limit, $merchant = [])
|
||||
{
|
||||
$financialType = FinancialRecordRepository::TYPE_CN_MAP;
|
||||
/*
|
||||
order 收入 公共 新订单
|
||||
brokerage_one 支出 公共 一级佣金
|
||||
brokerage_two 支出 公共 二级佣金
|
||||
order_charge 支出 商户 手续费
|
||||
order_true 支出 平台 商户入账
|
||||
refund_order 支出 公共 退款
|
||||
refund_brokerage_one 收入 公共 返还一级佣金
|
||||
refund_brokerage_two 收入 公共 返还二级佣金
|
||||
refund_charge 收入 商户 返还手续费
|
||||
refund_true 收入 平台 商户返还入账
|
||||
presell 收入 公共 新订单
|
||||
presell_charge 支出 商户 手续费
|
||||
presell_true 支出 平台 商户入账
|
||||
supply_chain 供应链商户入账
|
||||
*/
|
||||
$financialType = [
|
||||
'order' => '订单支付',
|
||||
'supply_chain' => '供应链',
|
||||
'presell' => '预售订单(尾款)',
|
||||
'brokerage_one' => '一级佣金',
|
||||
'brokerage_two' => '二级佣金',
|
||||
'order_charge' => '手续费',
|
||||
'order_true' => '商户入账',
|
||||
'refund_order' => '退款',
|
||||
'refund_charge' => '返还手续费',
|
||||
'refund_true' => '商户返还入账',
|
||||
'presell_charge' => '预售订单(手续费)',
|
||||
'presell_true' => '商户入账',
|
||||
'refund_brokerage_one' => '返还一级佣金',
|
||||
'refund_brokerage_two' => '返还二级佣金',
|
||||
'mer_presell' => '预售订单(总额)',
|
||||
'order_presell' => '预售订单(定金)',
|
||||
'refund_platform_coupon' => '退回优惠券补贴',
|
||||
'order_platform_coupon' => '优惠券补贴',
|
||||
'auto_margin' => '押金',
|
||||
'commission_to_service_team' => '订单平台佣金',
|
||||
'commission_to_platform' => '订单剩余平台手续费',
|
||||
'commission_to_village' => '订单平台佣金',
|
||||
'commission_to_town' => '订单平台佣金',
|
||||
'commission_to_service_team_refund' => '退回平台佣金',
|
||||
'commission_to_platform_refund' => '退回剩余平台手续费',
|
||||
'commission_to_village_refund' => '退回平台佣金',
|
||||
'commission_to_town_refund' => '退回平台佣金',
|
||||
'auto_margin_refund' => '退回押金',
|
||||
'commission_to_entry_merchant' => '订单平台佣金',//入口店铺佣金
|
||||
'commission_to_cloud_warehouse' => '订单平台佣金',//云仓佣金
|
||||
'commission_to_entry_merchant_refund' => '退回平台佣金',
|
||||
'commission_to_cloud_warehouse_refund' => '退回平台佣金',
|
||||
'first_order_commission' => '首单拉新',
|
||||
];
|
||||
$sys_pm_1 = ['auto_margin','order', 'presell', 'order_charge', 'order_presell', 'presell_charge', 'refund_brokerage_one', 'refund_brokerage_two', 'commission_to_platform'];
|
||||
$mer_pm_1 = ['first_order_commission','order_true','order', 'presell', 'refund_brokerage_one', 'refund_brokerage_two', 'mer_presell',
|
||||
'order_platform_coupon', 'commission_to_cloud_warehouse', 'commission_to_entry_merchant', 'commission_to_town', 'commission_to_village', 'commission_to_service_team'];
|
||||
$date_ = $where['date'];
|
||||
unset($where['date']);
|
||||
/** @var FinancialRecordRepository $make */
|
||||
$make = app()->make(FinancialRecordRepository::class);
|
||||
|
||||
$query = $make->search($where)->with(['orderInfo', 'refundOrder', 'merchant.merchantCategory']);
|
||||
@ -444,95 +488,6 @@ class ExcelService
|
||||
return compact('count', 'header', 'title', 'export', 'foot', 'filename');
|
||||
}
|
||||
|
||||
/**
|
||||
* 平台导出日月账单信息
|
||||
* @param array $where
|
||||
* @param int $page
|
||||
* @param int $limit
|
||||
* @param $merchant
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function exportFinancial2(array $where, int $page, int $limit, $merchant = [])
|
||||
{
|
||||
$financialType = FinancialRecordRepository::TYPE_CN_MAP;
|
||||
$date_ = $where['date'];
|
||||
unset($where['date']);
|
||||
/** @var FinancialRecordRepository $make */
|
||||
$make = app()->make(FinancialRecordRepository::class);
|
||||
$query = $make->search($where)->with(['orderInfo', 'refundOrder', 'merchant.merchantCategory']);
|
||||
if ($where['type'] == 1) {
|
||||
$title_ = '日账单';
|
||||
$start_date = $date_ . ' 00:00:00';
|
||||
$end_date = $date_ . ' 23:59:59';
|
||||
$query->whereDay('create_time', $date_);
|
||||
} else {
|
||||
$title_ = '月账单';
|
||||
$start_date = (date('Y-m-01', strtotime($date_)));
|
||||
$end_date = date('Y-m-d', strtotime("$start_date +1 month -1 day"));
|
||||
$query->whereMonth('create_time', $date_);
|
||||
}
|
||||
$query->where('financial_type', 'order');
|
||||
$income = $make->countIncome($where['type'], $where, $date_, $merchant);
|
||||
$expend = $make->countExpend($where['type'], $where, $date_, $merchant);
|
||||
$charge = bcsub($income['number'], $expend['number'], 2);
|
||||
$filename = $title_ . '(' . $date_ . ')' . time();
|
||||
$export = [];
|
||||
$limit = 20;
|
||||
$count = $query->count();
|
||||
$header = ['商户类别', '商户分类', '商户名称', '总订单号', '订单编号', '交易流水号', '交易时间', '对方信息', '交易类型', '收支金额', '备注'];
|
||||
$list = $query->page($page, $limit)->order('create_time DESC')->select();
|
||||
foreach ($list as $financialRecord) {
|
||||
$otherRecords = FinancialRecord::where('order_id', $financialRecord['order_id'])
|
||||
->whereIn('financial_type', ['commission_to_platform', 'platform_consumption', 'auto_margin', 'commission_to_promoter', 'merchant_order'])
|
||||
->field('financial_type,number')
|
||||
->select();
|
||||
$mark = [];
|
||||
foreach ($otherRecords as $otherRecord) {
|
||||
/** @var FinancialRecord $otherRecord */
|
||||
if (!empty($otherRecord->getMark())) {
|
||||
$mark[] = $otherRecord->getMark();
|
||||
}
|
||||
}
|
||||
if ($financialRecord['merchant']) {
|
||||
$exportItem = [
|
||||
$financialRecord['merchant']['is_trader'] ? '自营' : '非自营',
|
||||
$financialRecord['merchant']['merchantCategory']['category_name'] ?? '平台',
|
||||
$financialRecord['merchant']['mer_name'] ?? '平台',
|
||||
];
|
||||
}else{
|
||||
$exportItem = [
|
||||
'平台',
|
||||
'平台',
|
||||
'平台',
|
||||
];
|
||||
}
|
||||
$exportItem[] = ['groupOrder']['group_order_sn'] ?? '无数据';
|
||||
$exportItem[] = $financialRecord['order_sn'];
|
||||
$exportItem[] = $financialRecord['financial_record_sn'];
|
||||
$exportItem[] = $financialRecord['create_time'];
|
||||
$exportItem[] = $financialRecord['user_info'];
|
||||
$exportItem[] = $financialType[$financialRecord['financial_type']];
|
||||
$exportItem[] = $financialRecord['number'];
|
||||
$exportItem[] = implode(',', $mark);
|
||||
$export[] = $exportItem;
|
||||
}
|
||||
$foot = [
|
||||
'合计:平台应入账手续费 ' . $charge,
|
||||
'收入合计: ' . '订单支付' . $income['count'] . '笔,' . '实际支付金额共:' . $income['number'] . '元;',
|
||||
'支出合计: ' . '佣金支出' . $expend['count_brokerage'] . '笔,支出金额:' . $expend['number_brokerage'] . '元;商户入账支出' . $expend['count_order'] . '笔,支出金额:' . $expend['number_order'] . '元;退款手续费' . $expend['count_charge'] . '笔,支出金额' . $expend['number_charge'] . '元;合计支出' . $expend['number'],
|
||||
];
|
||||
$title = [
|
||||
$title_,
|
||||
$mer_name ?? '平台',
|
||||
'结算账期:【' . $start_date . '】至【' . $end_date . '】',
|
||||
'生成时间:' . date('Y-m-d H:i:s', time())
|
||||
];
|
||||
return compact('count', 'header', 'title', 'export', 'foot', 'filename');
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO 退款单导出
|
||||
* @param array $where
|
||||
@ -680,13 +635,8 @@ class ExcelService
|
||||
$query = app()->make(FinancialRepository::class)->search($where)->with('merchant');
|
||||
$count = $query->count();
|
||||
$list = $query->page($page, $limit)->select();
|
||||
|
||||
foreach ($list as $item) {
|
||||
if ($item->financial_type == 1) {
|
||||
if (empty($item->financial_account->bank)) {
|
||||
$acount = '';
|
||||
continue;
|
||||
}
|
||||
$acount = '姓名:' . $item->financial_account->name . PHP_EOL;
|
||||
$acount .= '银行名称:' . $item->financial_account->bank . PHP_EOL;
|
||||
$acount .= '银行卡号:' . $item->financial_account->bank_code;
|
||||
@ -716,59 +666,6 @@ class ExcelService
|
||||
return compact('count', 'header', 'title', 'export', 'foot', 'filename');
|
||||
}
|
||||
|
||||
/**
|
||||
* 提现银行账单导出
|
||||
* @param array $where
|
||||
* @param int $page
|
||||
* @param int $limit
|
||||
* @return array
|
||||
*/
|
||||
public function withdrawalBill(array $where, int $page, int $limit)
|
||||
{
|
||||
$title = [
|
||||
'转账记录',
|
||||
'生成时间:' . date('Y-m-d H:i:s', time())
|
||||
];
|
||||
$header = ['编号', '收款方账号', '收款方户名', '是否农业银行', '开户银行(行别)', '开户行大额行号', '开户行支行名称', '金额','用途(附言)'];
|
||||
$filename = '转账记录_' . time();
|
||||
$export = [];
|
||||
$where['type'] = 0; //申请类型默认为余额
|
||||
|
||||
$query = app()->make(FinancialRepository::class)->search($where)->with('merchant');
|
||||
|
||||
$count = $query->count();
|
||||
$list = $query->page($page, $limit)->select();
|
||||
foreach ($list as $item) {
|
||||
$checkRes = "";
|
||||
if (!empty($item->financial_account) && isset($item->financial_account->bank)) {
|
||||
$bankName = $item->financial_account->bank;
|
||||
if (preg_match("/农业银行/i", $bankName)) {
|
||||
$checkRes = "是";
|
||||
} else {
|
||||
$checkRes = "否";
|
||||
}
|
||||
}else{
|
||||
//测试数据有未存在的数据
|
||||
$bankName='';
|
||||
}
|
||||
|
||||
$export[] = [
|
||||
$item->financial_sn,
|
||||
$item->financial_account->bank_code??'',
|
||||
$item->financial_account->name??'',//收款方户名1
|
||||
$checkRes,
|
||||
$bankName,//'开户银行(行别)
|
||||
'',//'开户行大额行号'
|
||||
$item->financial_account->bank_branch??'',
|
||||
$item->extract_money,
|
||||
$item->mark
|
||||
];
|
||||
}
|
||||
$foot = '';
|
||||
return compact('count', 'header', 'title', 'export', 'foot', 'filename');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TODO 用户提现申请
|
||||
* @param array $where
|
||||
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace crmeb\utils;
|
||||
use Swoole\Coroutine\Http\Client;
|
||||
use function Swoole\Coroutine\run;
|
||||
|
||||
class AsynClient
|
||||
{
|
||||
|
||||
function post($host='',$url='',$data)
|
||||
{
|
||||
run(function () use($host,$url,$data) {
|
||||
$cli = new Client($host);
|
||||
$cli->post($url,$data);
|
||||
echo $cli->body;
|
||||
$cli->close();
|
||||
});
|
||||
}
|
||||
}
|
2
public/index.html
Normal file → Executable file
2
public/index.html
Normal file → Executable file
@ -2,4 +2,4 @@
|
||||
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')
|
||||
if(window.location.protocol == 'https:'){
|
||||
document.write('<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">')
|
||||
}</script><link rel=stylesheet href=/static/index.2da1efab.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/static/js/chunk-vendors.c6349b23.js></script><script src=/static/js/index.80ad0d12.js></script></body></html>
|
||||
}</script><link rel=stylesheet href=/static/index.97465e7b.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/static/js/chunk-vendors.3822bc6e.js></script><script src=/static/js/index.344418d8.js></script></body></html>
|
2
public/mer.html
Normal file → Executable file
2
public/mer.html
Normal file → Executable file
File diff suppressed because one or more lines are too long
0
public/mer/css/app.54d412cb.css
Normal file → Executable file
0
public/mer/css/app.54d412cb.css
Normal file → Executable file
0
public/mer/css/chunk-59dbe549.43ee60bd.css → public/mer/css/chunk-00584afe.43ee60bd.css
Normal file → Executable file
0
public/mer/css/chunk-59dbe549.43ee60bd.css → public/mer/css/chunk-00584afe.43ee60bd.css
Normal file → Executable file
0
public/mer/css/chunk-070bd4b2.1d14cc16.css → public/mer/css/chunk-01454a3c.1d14cc16.css
Normal file → Executable file
0
public/mer/css/chunk-070bd4b2.1d14cc16.css → public/mer/css/chunk-01454a3c.1d14cc16.css
Normal file → Executable file
0
public/mer/css/chunk-18734621.3ba83a49.css → public/mer/css/chunk-02ea1cc8.3ba83a49.css
Normal file → Executable file
0
public/mer/css/chunk-18734621.3ba83a49.css → public/mer/css/chunk-02ea1cc8.3ba83a49.css
Normal file → Executable file
0
public/mer/css/chunk-8666c17c.2b116af7.css → public/mer/css/chunk-031de214.2b116af7.css
Normal file → Executable file
0
public/mer/css/chunk-8666c17c.2b116af7.css → public/mer/css/chunk-031de214.2b116af7.css
Normal file → Executable file
0
public/mer/css/chunk-a3f6b180.8aadf067.css → public/mer/css/chunk-03944393.8aadf067.css
Normal file → Executable file
0
public/mer/css/chunk-a3f6b180.8aadf067.css → public/mer/css/chunk-03944393.8aadf067.css
Normal file → Executable file
0
public/mer/css/chunk-5ddc6ab4.da186745.css → public/mer/css/chunk-03cdbf88.da186745.css
Normal file → Executable file
0
public/mer/css/chunk-5ddc6ab4.da186745.css → public/mer/css/chunk-03cdbf88.da186745.css
Normal file → Executable file
@ -1 +0,0 @@
|
||||
.head[data-v-4168297b]{padding:30px 35px 25px}.head .full[data-v-4168297b]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.head .full .order_icon[data-v-4168297b]{width:60px;height:60px}.head .full .iconfont[data-v-4168297b]{color:#1890ff}.head .full .iconfont.sale-after[data-v-4168297b]{color:#90add5}.head .full .text[data-v-4168297b]{-ms-flex-item-align:center;align-self:center;-webkit-box-flex:1;-ms-flex:1;flex:1;min-width:0;padding-left:12px;font-size:13px;color:#606266}.head .full .text .title[data-v-4168297b]{margin-bottom:10px;font-weight:500;font-size:16px;line-height:16px;color:rgba(0,0,0,.85)}.head .full .text .order-num[data-v-4168297b]{padding-top:10px;white-space:nowrap}.head .list[data-v-4168297b]{display:-webkit-box;display:-ms-flexbox;display:flex;margin-top:20px;overflow:hidden;list-style:none;padding:0}.head .list .item[data-v-4168297b]{-webkit-box-flex:0;-ms-flex:none;flex:none;width:200px;font-size:14px;line-height:14px;color:rgba(0,0,0,.85)}.head .list .item .title[data-v-4168297b]{margin-bottom:12px;font-size:13px;line-height:13px;color:#666}.head .list .item .value1[data-v-4168297b]{color:#f56022}.head .list .item .value2[data-v-4168297b]{color:#1bbe6b}.head .list .item .value3[data-v-4168297b]{color:#1890ff}.head .list .item .value4[data-v-4168297b]{color:#6a7b9d}.head .list .item .value5[data-v-4168297b]{color:#f5222d}.el-tabs--border-card[data-v-4168297b]{-webkit-box-shadow:none;box-shadow:none;border-bottom:none}.section[data-v-4168297b]{padding:20px 0 5px;border-bottom:1px dashed #eee}.section .title[data-v-4168297b]{padding-left:10px;border-left:3px solid #1890ff;font-size:15px;line-height:15px;color:#303133}.section .list[data-v-4168297b]{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;list-style:none;padding:0}.section .item[data-v-4168297b]{-webkit-box-flex:0;-ms-flex:0 0 33.33333%;flex:0 0 33.33333%;display:-webkit-box;display:-ms-flexbox;display:flex;margin-top:16px;font-size:13px;color:#606266}.section .item[data-v-4168297b]:nth-child(3n+1){padding-right:20px}.section .item[data-v-4168297b]:nth-child(3n+2){padding-right:10px;padding-left:10px}.section .item[data-v-4168297b]:nth-child(3n+3){padding-left:20px}.section .value[data-v-4168297b]{-webkit-box-flex:1;-ms-flex:1;flex:1}.section .value image[data-v-4168297b]{display:inline-block;width:40px;height:40px;margin:0 12px 12px 0;vertical-align:middle}.tab[data-v-4168297b]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.tab .el-image[data-v-4168297b]{width:36px;height:36px;margin-right:10px}[data-v-4168297b] .el-drawer__body{overflow:auto}.gary[data-v-4168297b]{color:#aaa}.logistics[data-v-4168297b]{-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:10px 0}.logistics .logistics_img[data-v-4168297b]{width:45px;height:45px;margin-right:12px}.logistics .logistics_img img[data-v-4168297b]{width:100%;height:100%}.logistics .logistics_cent span[data-v-4168297b]{display:block;font-size:12px}.tabBox_tit[data-v-4168297b]{width:53%;font-size:12px!important;margin:0 2px 0 10px;letter-spacing:1px;padding:5px 0;-webkit-box-sizing:border-box;box-sizing:border-box}.pictures[data-v-889b05f8]{max-width:100%}.area-desc[data-v-889b05f8]{margin:0;color:#999;font-size:12px}.selWidth[data-v-889b05f8]{width:300px}.spBlock[data-v-889b05f8]{cursor:pointer;display:block;padding:5px 0}.check[data-v-889b05f8]{color:#00a2d4}.el-dropdown-link[data-v-889b05f8]{cursor:pointer;color:#409eff;font-size:12px}.el-icon-arrow-down[data-v-889b05f8]{font-size:12px}.tabBox_tit[data-v-889b05f8]{width:53%;font-size:12px!important;margin:0 2px 0 10px;letter-spacing:1px;padding:5px 0;-webkit-box-sizing:border-box;box-sizing:border-box}[data-v-889b05f8] .row-bg .cell{color:red!important}.headTab[data-v-889b05f8]{position:relative}.headTab .headBtn[data-v-889b05f8]{position:absolute;right:0;top:-6px}.dropdown[data-v-889b05f8]{padding:0 10px;border:1px solid #409eff;margin-right:10px;line-height:28px;border-radius:4px}
|
0
public/mer/css/chunk-6f0c9ba6.80f336aa.css → public/mer/css/chunk-048e53ee.80f336aa.css
Normal file → Executable file
0
public/mer/css/chunk-6f0c9ba6.80f336aa.css → public/mer/css/chunk-048e53ee.80f336aa.css
Normal file → Executable file
0
public/mer/css/chunk-e1e9a7f2.38d37ff5.css → public/mer/css/chunk-0493956f.38d37ff5.css
Normal file → Executable file
0
public/mer/css/chunk-e1e9a7f2.38d37ff5.css → public/mer/css/chunk-0493956f.38d37ff5.css
Normal file → Executable file
0
public/mer/css/chunk-9cb7f93a.be9e1835.css → public/mer/css/chunk-09296115.be9e1835.css
Normal file → Executable file
0
public/mer/css/chunk-9cb7f93a.be9e1835.css → public/mer/css/chunk-09296115.be9e1835.css
Normal file → Executable file
1
public/mer/css/chunk-09559b9c.53a844dd.css
Executable file
1
public/mer/css/chunk-09559b9c.53a844dd.css
Executable file
@ -0,0 +1 @@
|
||||
.head[data-v-343bb459]{padding:30px 35px 25px}.head .full[data-v-343bb459]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.head .full .order_icon[data-v-343bb459]{width:60px;height:60px}.head .full .iconfont[data-v-343bb459]{color:#1890ff}.head .full .iconfont.sale-after[data-v-343bb459]{color:#90add5}.head .full .text[data-v-343bb459]{-ms-flex-item-align:center;align-self:center;-webkit-box-flex:1;-ms-flex:1;flex:1;min-width:0;padding-left:12px;font-size:13px;color:#606266}.head .full .text .title[data-v-343bb459]{margin-bottom:10px;font-weight:500;font-size:16px;line-height:16px;color:rgba(0,0,0,.85)}.head .full .text .order-num[data-v-343bb459]{padding-top:10px;white-space:nowrap}.head .list[data-v-343bb459]{display:-webkit-box;display:-ms-flexbox;display:flex;margin-top:20px;overflow:hidden;list-style:none;padding:0}.head .list .item[data-v-343bb459]{-webkit-box-flex:0;-ms-flex:none;flex:none;width:200px;font-size:14px;line-height:14px;color:rgba(0,0,0,.85)}.head .list .item .title[data-v-343bb459]{margin-bottom:12px;font-size:13px;line-height:13px;color:#666}.head .list .item .value1[data-v-343bb459]{color:#f56022}.head .list .item .value2[data-v-343bb459]{color:#1bbe6b}.head .list .item .value3[data-v-343bb459]{color:#1890ff}.head .list .item .value4[data-v-343bb459]{color:#6a7b9d}.head .list .item .value5[data-v-343bb459]{color:#f5222d}.el-tabs--border-card[data-v-343bb459]{-webkit-box-shadow:none;box-shadow:none;border-bottom:none}.section[data-v-343bb459]{padding:20px 0 5px;border-bottom:1px dashed #eee}.section .title[data-v-343bb459]{padding-left:10px;border-left:3px solid #1890ff;font-size:15px;line-height:15px;color:#303133}.section .list[data-v-343bb459]{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;list-style:none;padding:0}.section .item[data-v-343bb459]{-webkit-box-flex:0;-ms-flex:0 0 33.33333%;flex:0 0 33.33333%;display:-webkit-box;display:-ms-flexbox;display:flex;margin-top:16px;font-size:13px;color:#606266}.section .item[data-v-343bb459]:nth-child(3n+1){padding-right:20px}.section .item[data-v-343bb459]:nth-child(3n+2){padding-right:10px;padding-left:10px}.section .item[data-v-343bb459]:nth-child(3n+3){padding-left:20px}.section .value[data-v-343bb459]{-webkit-box-flex:1;-ms-flex:1;flex:1}.section .value image[data-v-343bb459]{display:inline-block;width:40px;height:40px;margin:0 12px 12px 0;vertical-align:middle}.tab[data-v-343bb459]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.tab .el-image[data-v-343bb459]{width:36px;height:36px;margin-right:10px}[data-v-343bb459] .el-drawer__body{overflow:auto}.gary[data-v-343bb459]{color:#aaa}.logistics[data-v-343bb459]{-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:10px 0}.logistics .logistics_img[data-v-343bb459]{width:45px;height:45px;margin-right:12px}.logistics .logistics_img img[data-v-343bb459]{width:100%;height:100%}.logistics .logistics_cent span[data-v-343bb459]{display:block;font-size:12px}.tabBox_tit[data-v-343bb459]{width:53%;font-size:12px!important;margin:0 2px 0 10px;letter-spacing:1px;padding:5px 0;-webkit-box-sizing:border-box;box-sizing:border-box}.pictures[data-v-56bbdfa6]{max-width:100%}.area-desc[data-v-56bbdfa6]{margin:0;color:#999;font-size:12px}.selWidth[data-v-56bbdfa6]{width:300px}.spBlock[data-v-56bbdfa6]{cursor:pointer;display:block;padding:5px 0}.check[data-v-56bbdfa6]{color:#00a2d4}.el-dropdown-link[data-v-56bbdfa6]{cursor:pointer;color:#409eff;font-size:12px}.el-icon-arrow-down[data-v-56bbdfa6]{font-size:12px}.tabBox_tit[data-v-56bbdfa6]{width:53%;font-size:12px!important;margin:0 2px 0 10px;letter-spacing:1px;padding:5px 0;-webkit-box-sizing:border-box;box-sizing:border-box}[data-v-56bbdfa6] .row-bg .cell{color:red!important}.headTab[data-v-56bbdfa6]{position:relative}.headTab .headBtn[data-v-56bbdfa6]{position:absolute;right:0;top:-6px}.dropdown[data-v-56bbdfa6]{padding:0 10px;border:1px solid #409eff;margin-right:10px;line-height:28px;border-radius:4px}
|
0
public/mer/css/chunk-91422062.b24cfca2.css → public/mer/css/chunk-0b1f3772.b24cfca2.css
Normal file → Executable file
0
public/mer/css/chunk-91422062.b24cfca2.css → public/mer/css/chunk-0b1f3772.b24cfca2.css
Normal file → Executable file
0
public/mer/css/chunk-03c3baae.d76f77a2.css → public/mer/css/chunk-0d2c1415.d76f77a2.css
Normal file → Executable file
0
public/mer/css/chunk-03c3baae.d76f77a2.css → public/mer/css/chunk-0d2c1415.d76f77a2.css
Normal file → Executable file
0
public/mer/css/chunk-15d511ce.3f2a189e.css → public/mer/css/chunk-0fa0e81e.3f2a189e.css
Normal file → Executable file
0
public/mer/css/chunk-15d511ce.3f2a189e.css → public/mer/css/chunk-0fa0e81e.3f2a189e.css
Normal file → Executable file
0
public/mer/css/chunk-c1d68308.c270c7db.css → public/mer/css/chunk-0fdbbf98.c270c7db.css
Normal file → Executable file
0
public/mer/css/chunk-c1d68308.c270c7db.css → public/mer/css/chunk-0fdbbf98.c270c7db.css
Normal file → Executable file
0
public/mer/css/chunk-459bd835.3286df8c.css → public/mer/css/chunk-1306dfb6.3286df8c.css
Normal file → Executable file
0
public/mer/css/chunk-459bd835.3286df8c.css → public/mer/css/chunk-1306dfb6.3286df8c.css
Normal file → Executable file
0
public/mer/css/chunk-41e4e6b0.7c52b6c7.css → public/mer/css/chunk-1df22872.7c52b6c7.css
Normal file → Executable file
0
public/mer/css/chunk-41e4e6b0.7c52b6c7.css → public/mer/css/chunk-1df22872.7c52b6c7.css
Normal file → Executable file
0
public/mer/css/chunk-6802bfd3.9dd53540.css → public/mer/css/chunk-32c5a54a.9dd53540.css
Normal file → Executable file
0
public/mer/css/chunk-6802bfd3.9dd53540.css → public/mer/css/chunk-32c5a54a.9dd53540.css
Normal file → Executable file
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user