commit
bbde3743db
@ -51,6 +51,7 @@ class StoreConsumptionUserDao extends BaseDao
|
||||
|
||||
public $startTime;
|
||||
public $endTime;
|
||||
public $billExtra;
|
||||
|
||||
protected function getModel(): string
|
||||
{
|
||||
@ -236,12 +237,15 @@ 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) {
|
||||
$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'];
|
||||
@ -269,6 +273,9 @@ class StoreConsumptionUserDao extends BaseDao
|
||||
} 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,
|
||||
|
@ -41,6 +41,9 @@ class ProductAttrDao extends BaseDao
|
||||
*/
|
||||
public function insert(array $data)
|
||||
{
|
||||
foreach ($data as &$item) {
|
||||
$item['profit_rate'] = bcdiv(bcsub($item['price'], $item['procure_price'], 2), $item['price'], 2) * 100;
|
||||
}
|
||||
return ($this->getModel()::getDB())->insertAll($data);
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
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;
|
||||
@ -187,6 +188,18 @@ 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) {
|
||||
|
@ -131,6 +131,28 @@ 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)) {
|
||||
|
@ -16,6 +16,7 @@ class StoreConsumption extends BaseModel
|
||||
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
|
||||
{
|
||||
@ -27,4 +28,4 @@ class StoreConsumption extends BaseModel
|
||||
return 'store_consumption';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
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()) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
@ -589,4 +589,28 @@ 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ 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;
|
||||
|
||||
@ -316,4 +317,9 @@ class Merchant extends BaseModel
|
||||
return $this->hasOne(GeoStreet::class, 'street_code', 'street_id');
|
||||
}
|
||||
|
||||
public function promoter()
|
||||
{
|
||||
return User::where('uid', $this->uid)->value('spread_uid');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ 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,10 +84,13 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
$allowDelivery = true;
|
||||
$activityProductCount = 0;
|
||||
//判断是否是平台购物卡,购物卡不允许使用任何优惠券
|
||||
$merchantCate = $merchantCartList[0]['list'][0]->product->merCateId;
|
||||
$isPlatformCard = false;
|
||||
if (!empty($merchantCate) && in_array(env('PLATFORM_CARD_CATE_ID'), array_column($merchantCate->toArray(), 'mer_cate_id'))) {
|
||||
$isPlatformCard = true;
|
||||
$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');
|
||||
@ -271,7 +275,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
$enabledCoupon = !($order_type && $order_type != 2);
|
||||
|
||||
//只有预售和普通商品可以用优惠券
|
||||
if (!$enabledCoupon || $isPlatformCard) {
|
||||
if (!$enabledCoupon || $isPlatformCard || $isPickupCard) {
|
||||
$merchantCart['coupon'] = [];
|
||||
}
|
||||
$svip_coupon_merge = merchantConfig($merchantCart['mer_id'], 'svip_coupon_merge');
|
||||
@ -297,12 +301,18 @@ 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);
|
||||
@ -474,6 +484,9 @@ 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;
|
||||
|
||||
//单个商品实际支付金额
|
||||
@ -551,13 +564,27 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
'status' => 0,
|
||||
'is_fail' => 0
|
||||
];
|
||||
//抵扣券仅限官方店铺使用
|
||||
$isOfficialStore = true;
|
||||
foreach ($merchantCartList as $merchantCart) {
|
||||
if ($merchantCart['type_id'] != 22) {
|
||||
$isOfficialStore = false;
|
||||
}
|
||||
}
|
||||
if (!$isOfficialStore) {
|
||||
$ConsumptionWhere['type'] = 1;
|
||||
}
|
||||
|
||||
$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) {
|
||||
$item['describe'] = '仅限平台指定商家商品可使用';
|
||||
return $item;
|
||||
});
|
||||
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) {
|
||||
$item['describe'] = '仅限平台指定商家商品可使用';
|
||||
return $item;
|
||||
});
|
||||
}
|
||||
// }
|
||||
|
||||
$usePlatformCouponId = 0;
|
||||
@ -697,6 +724,9 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
}
|
||||
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;
|
||||
@ -797,7 +827,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
||||
if (($orderType == 98 || $orderType == 99) && count($merchantCartList) > 1) {
|
||||
throw new ValidateException('采购、委托商品不支持跨店购买');
|
||||
}
|
||||
if ($hasTake) {
|
||||
if ($hasTake && $orderInfo['source'] != 999) {
|
||||
app()->make(UserAddressValidate::class)->scene('take')->check($post);
|
||||
}
|
||||
|
||||
@ -831,6 +861,7 @@ 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'] ?: []);
|
||||
@ -851,6 +882,9 @@ 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']) : '';
|
||||
//整理订单数据
|
||||
@ -868,8 +902,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')),
|
||||
|
@ -22,6 +22,7 @@ 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;
|
||||
@ -230,6 +231,16 @@ class StoreOrderRepository extends BaseRepository
|
||||
(new StoreActivityDao())->saveOrderProduct(2, $order);
|
||||
$order->paid = 1;
|
||||
$order->pay_time = $time;
|
||||
if ($order->source == 999) {
|
||||
$order->status = 3;
|
||||
//订单确认收货,增加商户销售金额
|
||||
Merchant::where('mer_id', $order->mer_id)->update(['sale_amount' => Db::raw('sale_amount+' . $order->pay_price)]);
|
||||
//订单确认收货,增加商户采购金额
|
||||
$merId = Merchant::where('uid', $order->uid)->value('mer_id');
|
||||
if (!empty($merId)) {
|
||||
Merchant::where('mer_id', $merId)->update(['purchase_amount' => Db::raw('purchase_amount+' . $order->pay_price)]);
|
||||
}
|
||||
}
|
||||
$svipDiscount = bcadd($order->svip_discount, $svipDiscount, 2);
|
||||
if (isset($subOrders[$order->order_sn])) {
|
||||
$order->transaction_id = $subOrders[$order->order_sn]['transaction_id'];
|
||||
@ -288,7 +299,6 @@ 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);
|
||||
@ -304,37 +314,44 @@ 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');
|
||||
}
|
||||
|
||||
if ($order->source == 103) {
|
||||
$_payPrice = $order->procure_price;
|
||||
//市级供应链
|
||||
$product_mer_id = Db::name('store_order_product')->where('order_id', $order->order_id)->value('product_mer_id');
|
||||
// 平台支付市供应链流水账单数据
|
||||
$financeDao->platformOut($_payPrice, 'supply_chain', $product_mer_id);
|
||||
if ($product_mer_id) {
|
||||
//市级供应链押金计算
|
||||
if ($_payPrice > 0) {
|
||||
/** @var MerchantRepository $merchantRepo */
|
||||
$merchantRepo = app()->make(MerchantRepository::class);
|
||||
$merchantRepo->merId = $product_mer_id;
|
||||
$merchantRepo->forceMargin = false;
|
||||
[$_payCityPrice, $financeDao] = $merchantRepo->deductDeposit($_payPrice, $order, $financeDao);
|
||||
}
|
||||
if (isset($_payCityPrice)) {
|
||||
if (!$is_combine) {
|
||||
app()->make(MerchantRepository::class)->addLockMoney($product_mer_id, 'order', $order->order_id, $_payCityPrice);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$_payPrice = $order->pay_price;
|
||||
$_payPrice = bcsub($order->pay_price, bcadd($order['extension_one'], $order['extension_two'], 3), 2);
|
||||
|
||||
// 平台支出推广费
|
||||
$promoter = $order->merchant->promoter();
|
||||
if (!empty($promoter)) {
|
||||
$promoterCommission = bcmul($_payPrice, 0.003, 2);
|
||||
$financeDao->platformOut($promoterCommission, 'commission_to_promoter');
|
||||
}
|
||||
|
||||
// 平台收入手续费
|
||||
if ($order['commission_rate'] > 0) {
|
||||
$commission_rate = bcdiv((string)$order['commission_rate'],'100',6);
|
||||
$platformCommission = bcmul($_payPrice, (string)$commission_rate, 2);
|
||||
$_payPrice = bcsub($_payPrice, $platformCommission, 2);
|
||||
if (isset($promoterCommission) && $promoterCommission > 0) {
|
||||
$platformCommission = bcsub($platformCommission, $promoterCommission, 2);
|
||||
}
|
||||
$financeDao->platformIn($platformCommission, 'commission_to_platform', $order['mer_id']);
|
||||
}
|
||||
|
||||
if ($_payPrice > 0) {
|
||||
/** @var MerchantRepository $merchantRepo */
|
||||
$merchantRepo = app()->make(MerchantRepository::class);
|
||||
$merchantRepo->merId = $order['mer_id'];
|
||||
$merchantRepo->forceMargin = false;
|
||||
[$_payPrice, $financeDao] = $merchantRepo->deductDeposit($_payPrice, $order, $financeDao);
|
||||
}
|
||||
|
||||
// 商户收入金额
|
||||
$financeDao->platformOut($_payPrice, 'merchant_order', $order['mer_id']);
|
||||
|
||||
if ($is_combine) {
|
||||
$profitsharing[] = [
|
||||
'profitsharing_sn' => $storeOrderProfitsharingRepository->getOrderSn(),
|
||||
@ -357,14 +374,9 @@ class StoreOrderRepository extends BaseRepository
|
||||
], $order->mer_id);
|
||||
//自动打印订单
|
||||
$this->autoPrinter($order->order_id, $order->mer_id);
|
||||
if ($order['pay_price'] > 0 && $order['source'] == 103) {
|
||||
// "惠农供销,谱写数字新篇章"活动首单分润,商户和村、小组合伙人
|
||||
$financeDao = (new CommissionDao())->firstOrderCommission($order, $financeDao);
|
||||
}
|
||||
|
||||
//判断是否是平台购物卡
|
||||
$merchantCate = $order->orderProduct[0]->product->merCateId;
|
||||
if (!empty($merchantCate) && in_array(env('PLATFORM_CARD_CATE_ID'), array_column($merchantCate->toArray(), 'mer_cate_id'))) {
|
||||
if ($order->orderProduct[0]->product->isPlatformCard()) {
|
||||
//购物卡自动发货
|
||||
$deliveryData = [
|
||||
'delivery_type' => 3,
|
||||
@ -744,6 +756,22 @@ class StoreOrderRepository extends BaseRepository
|
||||
// 'number' => $order->extension_two,
|
||||
// ], $order->mer_id);
|
||||
}
|
||||
|
||||
$promoterCommission = FinancialRecord::where('order_id', $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
|
||||
]);
|
||||
$userRepository = app()->make(UserRepository::class);
|
||||
$userRepository->incBrokerage($promoterCommission['user_id'], $promoterCommission['number']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -767,6 +795,18 @@ class StoreOrderRepository extends BaseRepository
|
||||
$order->interest->save();
|
||||
}
|
||||
$order->save();
|
||||
|
||||
if ($order->uid != $order->merchant->uid) {
|
||||
$refundPrice = StoreRefundOrder::where('order_id', $order['order_id'])->where('status', '<>', -1)->sum('refund_price');
|
||||
$money = bcsub($order->pay_price, $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)]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -489,6 +489,17 @@ 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;
|
||||
|
@ -188,7 +188,7 @@ class StoreOtherOrderRepository extends BaseRepository
|
||||
$order->transaction_id = $subOrders[$order->order_sn]['transaction_id'];
|
||||
}
|
||||
$presell = false;
|
||||
|
||||
|
||||
// 订单的类型 0 发货 1 自提
|
||||
if ($order->order_type == 1 && $order->status != 10) {
|
||||
$order->verify_code = $this->verifyCode();
|
||||
@ -231,7 +231,7 @@ class StoreOtherOrderRepository extends BaseRepository
|
||||
|
||||
$_order_rate = 0;
|
||||
|
||||
//平台手续费
|
||||
//平台手续费
|
||||
if ($order['commission_rate'] > 0) {
|
||||
|
||||
$commission_rate = ($order['commission_rate'] / 100);
|
||||
@ -244,7 +244,7 @@ class StoreOtherOrderRepository extends BaseRepository
|
||||
}
|
||||
|
||||
if (!$presell) {
|
||||
|
||||
|
||||
if ($order['commission_rate'] > 0) {
|
||||
$finance[] = [
|
||||
'order_id' => $order->order_id,
|
||||
@ -320,7 +320,7 @@ class StoreOtherOrderRepository extends BaseRepository
|
||||
$this->giveIntegral($groupOrder);
|
||||
$financialRecordRepository->insertAll($finance);
|
||||
$storeOrderStatusRepository->batchCreateLog($orderStatus);
|
||||
$groupOrder->save();
|
||||
$groupOrder->save();
|
||||
Db::commit();
|
||||
|
||||
return true;
|
||||
@ -332,7 +332,7 @@ class StoreOtherOrderRepository extends BaseRepository
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
@ -957,10 +957,10 @@ class StoreOtherOrderRepository extends BaseRepository
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function runDelivery($id, $merId, $data, $split, $method, $service_id = 0)
|
||||
{
|
||||
return Db::transaction(function () use ($id, $merId, $data, $split, $method, $service_id) {
|
||||
@ -1063,7 +1063,7 @@ class StoreOtherOrderRepository extends BaseRepository
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function getOne($id, ?int $merId)
|
||||
@ -1280,10 +1280,12 @@ class StoreOtherOrderRepository extends BaseRepository
|
||||
'order_charge_lv'=>$item->merchant->commission_rate?round($item->merchant->commission_rate,2):0,
|
||||
];
|
||||
if(in_array($status,[4,5])){
|
||||
$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();
|
||||
$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{
|
||||
$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 = 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'] = json_decode($merchant['financial_bank'], true);
|
||||
$item['merchant'] = $merchant;
|
||||
});
|
||||
return compact('count', 'list');
|
||||
}
|
||||
@ -1504,7 +1506,7 @@ class StoreOtherOrderRepository extends BaseRepository
|
||||
return ExpressService::express($order->delivery_id, $order->delivery_name, $order->user_phone);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function batchPrinter(int $id, int $merId)
|
||||
{
|
||||
$order = $this->dao->getWhere(['order_id' => $id], '*', ['orderProduct', 'merchant' => function ($query) {
|
||||
@ -1662,7 +1664,7 @@ class StoreOtherOrderRepository extends BaseRepository
|
||||
return $count - $count_ - $count__;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
@ -1738,7 +1740,7 @@ class StoreOtherOrderRepository extends BaseRepository
|
||||
return $query->select();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function create_product_import_log($data, $status = 1)
|
||||
{
|
||||
$data = [
|
||||
|
@ -115,6 +115,10 @@ class ProductRepository extends BaseRepository
|
||||
'msg' => '被下架'
|
||||
],
|
||||
];
|
||||
|
||||
/** @var bool $force 忽略商品状态 */
|
||||
public $force = false;
|
||||
|
||||
/**
|
||||
* ProductRepository constructor.
|
||||
* @param dao $dao
|
||||
@ -1206,6 +1210,9 @@ 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);
|
||||
}
|
||||
|
||||
@ -1955,6 +1962,9 @@ 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']);
|
||||
|
@ -582,6 +582,7 @@ class SpuRepository extends BaseRepository
|
||||
];
|
||||
break;
|
||||
case 2:
|
||||
/** @var ProductPresellRepository $_make */
|
||||
$_make = app()->make(ProductPresellRepository::class);
|
||||
$res = $_make->getWhere([$_make->getPk() => $id]);
|
||||
$where = [
|
||||
|
@ -31,10 +31,54 @@ class FinancialRecordRepository extends BaseRepository
|
||||
{
|
||||
|
||||
public $commonFinancialType = [
|
||||
'order', 'order_refund', 'brokerage_one', 'brokerage_two', 'refund_brokerage_one', 'refund_brokerage_two', 'refund_order','order_platform_coupon',
|
||||
'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'
|
||||
,'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'
|
||||
];
|
||||
|
||||
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)
|
||||
@ -60,6 +104,7 @@ class FinancialRecordRepository extends BaseRepository
|
||||
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');
|
||||
}
|
||||
@ -782,4 +827,15 @@ class FinancialRecordRepository extends BaseRepository
|
||||
|
||||
return compact('count', 'number');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取财务类型
|
||||
* @param $type
|
||||
* @return string
|
||||
*/
|
||||
public function getFinancialTypeCn($type)
|
||||
{
|
||||
return self::TYPE_CN_MAP[$type] ?? '';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
namespace app\common\repositories\system\merchant;
|
||||
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\model\system\merchant\MerchantIntention;
|
||||
use app\common\repositories\BaseRepository;
|
||||
use crmeb\jobs\SendSmsJob;
|
||||
use crmeb\services\SmsService;
|
||||
@ -100,6 +102,7 @@ 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) {
|
||||
@ -117,6 +120,7 @@ class MerchantIntentionRepository extends BaseRepository
|
||||
$data['is_margin'] = $margin['is_margin'] ?? -1;
|
||||
$data['margin'] = $margin['margin'] ?? 0;
|
||||
$merData = [];
|
||||
$smsData = [];
|
||||
if ($create) {
|
||||
$password = substr($intention['phone'], -6);
|
||||
$merData = [
|
||||
@ -172,7 +176,7 @@ class MerchantIntentionRepository extends BaseRepository
|
||||
}
|
||||
Db::transaction(function () use ($config, $intention, $data, $create,$margin,$merData,$smsData,$autoCreate) {
|
||||
if ($data['status'] == 1) {
|
||||
if ($create && $intention['type'] == 1) {
|
||||
if ($create) {
|
||||
$merchant = app()->make(MerchantRepository::class)->createMerchant($merData);
|
||||
$data['mer_id'] = $merchant->mer_id;
|
||||
$data['uid'] = $intention['uid'];
|
||||
@ -194,7 +198,15 @@ class MerchantIntentionRepository extends BaseRepository
|
||||
$store_service_data['create_time'] = date('Y-m-d H:i:s');
|
||||
Db::name('store_service')->insert($store_service_data);
|
||||
}
|
||||
Queue::push(SendSmsJob::class, ['tempId' => 'APPLY_MER_SUCCESS', 'id' => $smsData]);
|
||||
if ($intention['type'] == 2) {
|
||||
$merId = MerchantIntention::where('uid', $intention['uid'])->where('status', 1)->value('mer_id');
|
||||
if (!empty($merId)) {
|
||||
Merchant::where('mer_id', $merId)->update(['business_status' => 2]);
|
||||
}
|
||||
}
|
||||
if (!empty($smsData)) {
|
||||
Queue::push(SendSmsJob::class, ['tempId' => 'APPLY_MER_SUCCESS', 'id' => $smsData]);
|
||||
}
|
||||
} else {
|
||||
Queue::push(SendSmsJob::class, ['tempId' => 'APPLY_MER_FAIL', 'id' => $smsData]);
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
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;
|
||||
@ -269,7 +270,7 @@ class MerchantRepository extends BaseRepository
|
||||
$margin = app()->make(MerchantTypeRepository::class)->get($data['type_id']);
|
||||
$data['is_margin'] = $margin['is_margin'] ?? -1;
|
||||
$data['margin'] = $margin['margin'] ?? 0;
|
||||
|
||||
|
||||
return Db::transaction(function () use ($data, $make) {
|
||||
$account = $data['mer_account'];
|
||||
$password = $data['mer_password'];
|
||||
@ -410,12 +411,17 @@ class MerchantRepository extends BaseRepository
|
||||
/**
|
||||
* @Author:Qinii
|
||||
* @Date: 2020/5/30
|
||||
* @param int $id
|
||||
* @param int $merId
|
||||
* @param int $pid
|
||||
* @return mixed
|
||||
*/
|
||||
public function categoryList(int $id)
|
||||
public function categoryList(int $merId, int $pid = 0)
|
||||
{
|
||||
return app()->make(StoreCategoryRepository::class)->getApiFormatList($id, 1);
|
||||
if ($pid == 0) {
|
||||
return app()->make(StoreCategoryRepository::class)->getApiFormatList($merId, 1);
|
||||
} else {
|
||||
return app()->make(StoreCategoryDao::class)->children($pid, $merId);
|
||||
}
|
||||
}
|
||||
|
||||
public function wxQrcode($merId)
|
||||
|
@ -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) {
|
||||
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) {
|
||||
$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) {
|
||||
|
@ -1557,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', '')->order('id', 'desc')->find()) ?? (object)[];
|
||||
$android = (Db::name('AppUpdate')->where('type', 1)->where('phone_brand', '')->where('is_wget',0)->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 {
|
||||
|
@ -2,7 +2,11 @@
|
||||
|
||||
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;
|
||||
@ -63,4 +67,123 @@ class Store extends BaseController
|
||||
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);
|
||||
}
|
||||
} 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';
|
||||
foreach ($consumption['config'] as $k => $item) {
|
||||
if (empty($userConsumption) && in_array($merchant['type_id'], $item['type_id'])) {
|
||||
$saleTarget = $item['amount'];
|
||||
$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'];
|
||||
$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,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 红包获取记录
|
||||
* @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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -128,9 +128,10 @@ 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));
|
||||
return app('json')->success($this->repository->categoryList($id, $pid));
|
||||
}
|
||||
|
||||
public function qrcode($id)
|
||||
|
@ -184,16 +184,33 @@ class MerchantIntention extends BaseController
|
||||
return app('json')->fail('未开启商户入驻');
|
||||
}
|
||||
if ($this->userInfo) $data['uid'] = $this->userInfo->uid;
|
||||
$merInfo = Db::name('merchant')->where('uid', $this->userInfo->uid)->where('status', 1)->find();
|
||||
if (empty($merInfo)) {
|
||||
$settleIn = $this->repository->getWhere(['type' => 1, 'uid' => $data['uid'], 'is_del' => 0]);
|
||||
if (empty($settleIn)) {
|
||||
return app('json')->fail('请申请商户入驻申请!');
|
||||
}
|
||||
if (!empty($merInfo['business_status']) && ($merInfo['business_status'] == 1)) {
|
||||
if ($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)) {
|
||||
return app('json')->fail('商户交易已申请,正在审核中!');
|
||||
}
|
||||
if (!empty($merInfo['business_status']) && ($merInfo['business_status'] == 2)) {
|
||||
if (!empty($merIntentionInfo) && ($merIntentionInfo['status'] == 1)) {
|
||||
return app('json')->fail('商户交易申请已通过');
|
||||
}
|
||||
$intenInfo['phone'] = $settleIn['phone'];
|
||||
$intenInfo['mer_name'] = $settleIn['mer_name'];
|
||||
$intenInfo['company_name'] = $settleIn['company_name'];
|
||||
$intenInfo['name'] = $settleIn['name'];
|
||||
$intenInfo['social_credit_code'] = $settleIn['social_credit_code'];
|
||||
$intenInfo['images'] = $settleIn['images'];
|
||||
$intenInfo['merchant_category_id'] = $settleIn['merchant_category_id'];
|
||||
$intenInfo['mer_type_id'] = $settleIn['mer_type_id'];
|
||||
$intenInfo['area_id'] = $settleIn['area_id'];
|
||||
$intenInfo['street_id'] = $settleIn['street_id'];
|
||||
$intenInfo['village_id'] = $settleIn['village_id'];
|
||||
$intenInfo['is_nmsc'] = $settleIn['is_nmsc'];
|
||||
$intenInfo['address'] = $settleIn['address'];
|
||||
$intenInfo['bank_username'] = $data['bank_username'];
|
||||
$intenInfo['bank_opening'] = $data['bank_opening'];
|
||||
$intenInfo['bank_code'] = $data['bank_code'];
|
||||
@ -201,6 +218,7 @@ 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');
|
||||
|
46
app/controller/api/store/order/ScanPay.php
Normal file
46
app/controller/api/store/order/ScanPay.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?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');
|
||||
$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,6 +31,7 @@ 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
|
||||
@ -142,6 +143,9 @@ 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']]);
|
||||
}
|
||||
@ -255,7 +259,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]]);
|
||||
$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']);
|
||||
$validate->check($data);
|
||||
if ($data['spread_id']) {
|
||||
if ($data['spread_id'] !== $this->request->userInfo()->uid){
|
||||
|
@ -12,6 +12,7 @@ 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;
|
||||
@ -64,17 +65,19 @@ class StoreSpu extends BaseController
|
||||
'category_id',
|
||||
'type_code',
|
||||
'village_id',
|
||||
'location'
|
||||
'location',
|
||||
'sys_labels',
|
||||
'deduction_rate'
|
||||
]);
|
||||
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 (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']) {
|
||||
$arr = ['status' => 1, 'mer_state' => 1, 'is_del' => 0];
|
||||
$query = Merchant::where($arr);
|
||||
@ -161,7 +164,7 @@ 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'
|
||||
'keyword', 'cate_id', 'order', 'price_on', 'price_off', 'brand_id', 'pid', 'mer_cate_id', ['product_type', 0], 'action', 'common', 'deduction_rate'
|
||||
]);
|
||||
if ($where['action']) unset($where['product_type']);
|
||||
$where['mer_id'] = $id;
|
||||
@ -416,4 +419,12 @@ 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -545,6 +545,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]);
|
||||
|
@ -68,7 +68,7 @@ class OrderOther extends BaseController
|
||||
}
|
||||
$where['paid']=1;
|
||||
if($where['source']<=0){
|
||||
$where['source']=105;
|
||||
$where['source']=12;
|
||||
}
|
||||
return app('json')->success($this->repository->merchantGetList($where, $page, $limit));
|
||||
}
|
||||
|
@ -57,6 +57,8 @@ return [
|
||||
\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],
|
||||
|
@ -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"
|
||||
"alibabacloud/ocr-20191230": "^3.0",
|
||||
"overtrue/pinyin": "^4.1"
|
||||
},
|
||||
"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": "58b44ebbb4f75dc8b47bcaa0ae8327f7",
|
||||
"content-hash": "410f10b19a4e2c799d95f6050fd87e73",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adbario/php-dot-notation",
|
||||
@ -2635,7 +2635,7 @@
|
||||
"version": "4.1.0",
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://mirrors.cloud.tencent.com/repository/composer/overtrue/pinyin/4.1.0/overtrue-pinyin-4.1.0.zip",
|
||||
"url": "https://mirrors.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.1.0"
|
||||
"plugin-api-version": "2.3.0"
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ namespace crmeb\listens;
|
||||
|
||||
use app\common\model\store\consumption\StoreConsumption;
|
||||
use app\common\model\store\consumption\StoreConsumptionUser;
|
||||
use app\common\model\store\order\StoreOrder;
|
||||
use app\common\model\system\merchant\Merchant;
|
||||
use app\common\model\user\UserBill;
|
||||
use crmeb\interfaces\ListenerInterface;
|
||||
@ -29,12 +28,8 @@ class ActivateConsumptionListen extends TimerService implements ListenerInterfac
|
||||
->where('status', StoreConsumptionUser::STATUS_REPEAL)
|
||||
->select();
|
||||
foreach ($storeConsumptionUser as $item) {
|
||||
$isUsed = StoreConsumptionUser::where('order_id_set', $item['order_id_set'])
|
||||
->where('balance', 0)
|
||||
->count();
|
||||
$merchantId = Merchant::where('uid', $item['uid'])->value('mer_id');
|
||||
$saleTotal = StoreOrder::where('mer_id', $merchantId)->whereIn('status', [2, 3])->sum('pay_price');
|
||||
if ($saleTotal >= $item['order_amount'] && $isUsed > 0) {
|
||||
$saleTotal = Merchant::where('uid', $item['uid'])->value('sale_amount');
|
||||
if ($saleTotal >= $item['order_amount'] && $item['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'));
|
||||
|
@ -16,8 +16,7 @@ class OrderDeliveryListen implements ListenerInterface
|
||||
{
|
||||
$order = $event['order'];
|
||||
foreach ($order->orderProduct as $orderProduct) {
|
||||
$merchantCate = $orderProduct->product->merCateId;
|
||||
if (empty($merchantCate) || $merchantCate[0]['mer_cate_id'] != env('PLATFORM_CARD_CATE_ID')) {
|
||||
if (!$orderProduct->product->isPlatformCard()) {
|
||||
continue;
|
||||
}
|
||||
$consumption = StoreConsumption::where('type', StoreConsumption::TYPE_PULL_CONSUMPTION)->find();
|
||||
|
58
crmeb/listens/SendSubsidyCouponListen.php
Normal file
58
crmeb/listens/SendSubsidyCouponListen.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?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,
|
||||
];
|
||||
$consumptionRepo->send($consumption, 1, $merchant->uid, 0, $amount, StoreConsumptionUser::STATUS_UNUSED, StoreConsumptionUser::TYPE_TWO);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Log::info('定时任务:发放商户采购补贴券,成功数量:' . $count);
|
||||
} catch (\Throwable $e) {
|
||||
Log::info('定时任务:发放商户采购补贴券,error => ' . $e->getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
36
crmeb/listens/SetProductProfitRateListen.php
Normal file
36
crmeb/listens/SetProductProfitRateListen.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?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());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -321,57 +321,7 @@ class ExcelService
|
||||
*/
|
||||
public function exportFinancial(array $where, int $page, int $limit, $merchant = [])
|
||||
{
|
||||
/*
|
||||
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' => '首单拉新',
|
||||
];
|
||||
$financialType = FinancialRecordRepository::TYPE_CN_MAP;
|
||||
$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'];
|
||||
|
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
[data-v-c83f8ea6] table .el-image{display:inline-block!important}
|
@ -1 +0,0 @@
|
||||
.box-container[data-v-abd0a7d6]{overflow:hidden}.box-container .list[data-v-abd0a7d6]{float:left;line-height:40px}.box-container .sp[data-v-abd0a7d6]{width:50%}.box-container .sp3[data-v-abd0a7d6]{width:33.3333%}.box-container .sp100[data-v-abd0a7d6]{width:100%}.box-container .list .name[data-v-abd0a7d6]{display:inline-block;width:150px;text-align:right;color:#606266}.box-container .list.image[data-v-abd0a7d6]{margin-bottom:40px}.box-container .list.image img[data-v-abd0a7d6]{position:relative;top:40px}[data-v-abd0a7d6] .el-form-item__content .el-rate{position:relative;top:8px}
|
1
public/system/css/chunk-36cc5fbc.34517289.css
Normal file
1
public/system/css/chunk-36cc5fbc.34517289.css
Normal file
@ -0,0 +1 @@
|
||||
.box-container[data-v-55b426c8]{overflow:hidden}.box-container .list[data-v-55b426c8]{float:left;line-height:40px}.box-container .sp[data-v-55b426c8]{width:50%}.box-container .sp3[data-v-55b426c8]{width:33.3333%}.box-container .sp100[data-v-55b426c8]{width:100%}.box-container .list .name[data-v-55b426c8]{display:inline-block;width:150px;text-align:right;color:#606266}.box-container .list.image[data-v-55b426c8]{margin-bottom:40px}.box-container .list.image img[data-v-55b426c8]{position:relative;top:40px}[data-v-55b426c8] .el-form-item__content .el-rate{position:relative;top:8px}
|
1
public/system/css/chunk-391e6867.0ec5dcf4.css
Normal file
1
public/system/css/chunk-391e6867.0ec5dcf4.css
Normal file
@ -0,0 +1 @@
|
||||
[data-v-d696a35a] table .el-image{display:inline-block!important}
|
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