commit
29d35a6fbe
@ -13,9 +13,12 @@
|
|||||||
|
|
||||||
use app\common\repositories\system\config\ConfigValueRepository;
|
use app\common\repositories\system\config\ConfigValueRepository;
|
||||||
use app\common\repositories\system\groupData\GroupDataRepository;
|
use app\common\repositories\system\groupData\GroupDataRepository;
|
||||||
|
use crmeb\jobs\SendSmsJob;
|
||||||
use crmeb\services\UploadService;
|
use crmeb\services\UploadService;
|
||||||
use Swoole\Lock;
|
use Swoole\Lock;
|
||||||
use think\db\BaseQuery;
|
use think\db\BaseQuery;
|
||||||
|
use think\facade\Db;
|
||||||
|
use think\facade\Queue;
|
||||||
|
|
||||||
if (!function_exists('go')) {
|
if (!function_exists('go')) {
|
||||||
function go(): bool
|
function go(): bool
|
||||||
@ -1152,5 +1155,28 @@ if (!function_exists('checkSuffix')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!function_exists('Financial_Operations')) {
|
||||||
|
|
||||||
|
function Financial_Operations($activity_type,$order_id,$tempId='ORDER_CREATE',$id=0){
|
||||||
|
//发送运营财务短信
|
||||||
|
$group_id=0;
|
||||||
|
if($activity_type==98){
|
||||||
|
$group_id=Db::name('system_group')->where('group_key','city_operations')->value('group_id');
|
||||||
|
}else{
|
||||||
|
$group_id=Db::name('system_group')->where('group_key','town_operation')->value('group_id');
|
||||||
|
}
|
||||||
|
if($group_id){
|
||||||
|
$group_value=Db::name('system_group_data')->where('group_id',$group_id)->column('value');
|
||||||
|
if($group_value){
|
||||||
|
foreach($group_value as $k=>$v){
|
||||||
|
$phone=json_decode($v,true);
|
||||||
|
Queue::push(SendSmsJob::class, ['tempId' => $tempId, 'phone' => $phone['phone'],'orderId'=>$order_id,'id'=>$id]);//短信通知
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -722,6 +722,9 @@ class StoreOtherOrderCreateRepository extends StoreOtherOrderRepository
|
|||||||
Db::name('store_order_product_other')->insertAll($orderProduct);
|
Db::name('store_order_product_other')->insertAll($orderProduct);
|
||||||
return $groupOrder;
|
return $groupOrder;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//下单发送运营财务短信
|
||||||
|
Financial_Operations(98,$groupOrder['group_order_sn'],'ORDER_CREATE');
|
||||||
return $group;
|
return $group;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ class StoreOtherOrderRepository extends BaseRepository
|
|||||||
|
|
||||||
$_payPrice = bcsub($_payPrice, $_order_rate, 2);
|
$_payPrice = bcsub($_payPrice, $_order_rate, 2);
|
||||||
// 结算各镇 小组佣金
|
// 结算各镇 小组佣金
|
||||||
event('order.paySuccessOrder', compact('order', '_order_rate'));
|
event('order.paySuccessOrderOther', compact('order', '_order_rate'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$presell) {
|
if (!$presell) {
|
||||||
@ -298,6 +298,12 @@ class StoreOtherOrderRepository extends BaseRepository
|
|||||||
// if (!$is_combine) {
|
// if (!$is_combine) {
|
||||||
// app()->make(MerchantRepository::class)->addLockMoney($order->mer_id, 'order', $order->order_id, $_payPrice);
|
// app()->make(MerchantRepository::class)->addLockMoney($order->mer_id, 'order', $order->order_id, $_payPrice);
|
||||||
// }
|
// }
|
||||||
|
//短信 订单通知商户
|
||||||
|
$mer_phone=Db::name('merchant')->where('mer_id',$order->mer_id)->value('mer_phone');
|
||||||
|
if($mer_phone){
|
||||||
|
Queue::push(SendSmsJob::class, ['tempId' => 'ORDER_CREATE', 'phone' => $mer_phone,'orderId'=>$order->order_id,'id'=>0]);//短信通知
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
$userMerchantRepository->updatePayTime($uid, $order->mer_id, $order->pay_price);
|
$userMerchantRepository->updatePayTime($uid, $order->mer_id, $order->pay_price);
|
||||||
SwooleTaskService::merchant('notice', [
|
SwooleTaskService::merchant('notice', [
|
||||||
@ -309,22 +315,6 @@ class StoreOtherOrderRepository extends BaseRepository
|
|||||||
]
|
]
|
||||||
], $order->mer_id);
|
], $order->mer_id);
|
||||||
|
|
||||||
$group_id=0;
|
|
||||||
if($order->activity_type==98){
|
|
||||||
$group_id=Db::name('system_group')->where('group_key','city_operations')->value('group_id');
|
|
||||||
}else{
|
|
||||||
$group_id=Db::name('system_group')->where('group_key','town_operation')->value('group_id');
|
|
||||||
}
|
|
||||||
if($group_id){
|
|
||||||
$group_value=Db::name('system_group_data')->where('group_id',$group_id)->column('value');
|
|
||||||
if($group_value){
|
|
||||||
foreach($group_value as $k=>$v){
|
|
||||||
$phone=json_decode($v,true);
|
|
||||||
Queue::push(SendSmsJob::class, ['tempId' => 'ORDER_CREATE', 'phone' => $phone['phone'],'orderId'=>$order->order_id,'id'=>0]);//短信通知
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->giveIntegral($groupOrder);
|
$this->giveIntegral($groupOrder);
|
||||||
@ -332,6 +322,7 @@ class StoreOtherOrderRepository extends BaseRepository
|
|||||||
$storeOrderStatusRepository->batchCreateLog($orderStatus);
|
$storeOrderStatusRepository->batchCreateLog($orderStatus);
|
||||||
$groupOrder->save();
|
$groupOrder->save();
|
||||||
Db::commit();
|
Db::commit();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Log::error('财务点击支付失败'.$e->getMessage());
|
Log::error('财务点击支付失败'.$e->getMessage());
|
||||||
@ -615,6 +606,8 @@ class StoreOtherOrderRepository extends BaseRepository
|
|||||||
$this->takeAfter($order, $user);
|
$this->takeAfter($order, $user);
|
||||||
$order->save();
|
$order->save();
|
||||||
$storeOrderStatusRepository->{$func}($orderStatus);
|
$storeOrderStatusRepository->{$func}($orderStatus);
|
||||||
|
Financial_Operations(98,$order->order_id,'OTHER_ADMIN_TAKE_DELIVERY_CODE',$order->order_id);
|
||||||
|
|
||||||
});
|
});
|
||||||
// event('order.take', compact('order'));
|
// event('order.take', compact('order'));
|
||||||
}
|
}
|
||||||
@ -1256,9 +1249,6 @@ class StoreOtherOrderRepository extends BaseRepository
|
|||||||
$query = $this->dao->search($where, null)->where($this->getOrderType($status))
|
$query = $this->dao->search($where, null)->where($this->getOrderType($status))
|
||||||
->with([
|
->with([
|
||||||
'orderProduct',
|
'orderProduct',
|
||||||
'merchant' => function ($query) {
|
|
||||||
return $query->field('mer_id,mer_name,is_trader,financial_bank,auto_margin_rate,commission_rate');
|
|
||||||
},
|
|
||||||
'verifyService' => function ($query) {
|
'verifyService' => function ($query) {
|
||||||
return $query->field('service_id,nickname');
|
return $query->field('service_id,nickname');
|
||||||
},
|
},
|
||||||
@ -1278,7 +1268,7 @@ class StoreOtherOrderRepository extends BaseRepository
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
$count = $query->count();
|
$count = $query->count();
|
||||||
$list = $query->page($page, $limit)->select()->each(function ($item) {
|
$list = $query->page($page, $limit)->select()->each(function ($item) use($status){
|
||||||
$auto_margin= Db::name('financial_record_transfer')
|
$auto_margin= Db::name('financial_record_transfer')
|
||||||
->where('order_id',$item['order_id'])->where('financial_type','auto_margin')->where('financial_pm',0)->value('number');
|
->where('order_id',$item['order_id'])->where('financial_type','auto_margin')->where('financial_pm',0)->value('number');
|
||||||
$order_charge= Db::name('financial_record_transfer')
|
$order_charge= Db::name('financial_record_transfer')
|
||||||
@ -1289,6 +1279,11 @@ class StoreOtherOrderRepository extends BaseRepository
|
|||||||
'order_charge'=>$order_charge,
|
'order_charge'=>$order_charge,
|
||||||
'order_charge_lv'=>$item->merchant->commission_rate?round($item->merchant->commission_rate,2):0,
|
'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();
|
||||||
|
}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();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return compact('count', 'list');
|
return compact('count', 'list');
|
||||||
}
|
}
|
||||||
|
@ -41,33 +41,34 @@ class FinancialRepository extends BaseRepository
|
|||||||
Elm::radio('financial_type', '转账类型', $merchant->financial_type)
|
Elm::radio('financial_type', '转账类型', $merchant->financial_type)
|
||||||
->setOptions([
|
->setOptions([
|
||||||
['value' => 1, 'label' => '银行卡'],
|
['value' => 1, 'label' => '银行卡'],
|
||||||
['value' => 2, 'label' => '微信'],
|
// ['value' => 2, 'label' => '微信'],
|
||||||
['value' => 3, 'label' => '支付宝'],
|
// ['value' => 3, 'label' => '支付宝'],
|
||||||
])->control([
|
])->control([
|
||||||
[
|
[
|
||||||
'value' => 1,
|
'value' => 1,
|
||||||
'rule'=> [
|
'rule'=> [
|
||||||
Elm::input('name', '姓名')->value($merchant->financial_bank->name??'')->required(),
|
Elm::input('name', '公司名称')->value($merchant->financial_bank->name??'')->required(),
|
||||||
Elm::input('bank', '开户银行')->value($merchant->financial_bank->bank??'')->required(),
|
Elm::input('bank', '开户银行')->value($merchant->financial_bank->bank??'')->required(),
|
||||||
Elm::input('bank_code', '银行卡号')->value($merchant->financial_bank->bank_code??'')->required(),
|
Elm::input('bank_code', '对公账号')->value($merchant->financial_bank->bank_code??'')->required(),
|
||||||
]
|
Elm::input('bank_branch', '开户网点')->value($merchant->financial_bank->bank_branch??'')->required(),
|
||||||
],
|
|
||||||
[
|
|
||||||
'value' => 2,
|
|
||||||
'rule'=> [
|
|
||||||
Elm::input('name', '姓名')->value($merchant->financial_wechat->name??'')->required(),
|
|
||||||
Elm::input('wechat', '微信号')->value($merchant->financial_wechat->wechat??'')->required(),
|
|
||||||
Elm::frameImage('wechat_code', '收款二维码', '/' . config('admin.merchant_prefix') . '/setting/uploadPicture?field=wechat_code&type=1')->value($merchant->financial_wechat->wechat_code??'')->modal(['modal' => false])->width('896px')->height('480px'),
|
|
||||||
]
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'value' => 3,
|
|
||||||
'rule'=> [
|
|
||||||
Elm::input('name', '姓名')->value($merchant->financial_alipay->name??'')->required(),
|
|
||||||
Elm::input('alipay', '支付宝账号')->value($merchant->financial_alipay->alipay??'')->required(),
|
|
||||||
Elm::frameImage('alipay_code', '收款二维码', '/' . config('admin.merchant_prefix') . '/setting/uploadPicture?field=alipay_code&type=1')->value($merchant->financial_alipay->alipay_code??'')->modal(['modal' => false])->width('896px')->height('480px'),
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
// [
|
||||||
|
// 'value' => 2,
|
||||||
|
// 'rule'=> [
|
||||||
|
// Elm::input('name', '姓名')->value($merchant->financial_wechat->name??'')->required(),
|
||||||
|
// Elm::input('wechat', '微信号')->value($merchant->financial_wechat->wechat??'')->required(),
|
||||||
|
// Elm::frameImage('wechat_code', '收款二维码', '/' . config('admin.merchant_prefix') . '/setting/uploadPicture?field=wechat_code&type=1')->value($merchant->financial_wechat->wechat_code??'')->modal(['modal' => false])->width('896px')->height('480px'),
|
||||||
|
// ]
|
||||||
|
// ],
|
||||||
|
// [
|
||||||
|
// 'value' => 3,
|
||||||
|
// 'rule'=> [
|
||||||
|
// Elm::input('name', '姓名')->value($merchant->financial_alipay->name??'')->required(),
|
||||||
|
// Elm::input('alipay', '支付宝账号')->value($merchant->financial_alipay->alipay??'')->required(),
|
||||||
|
// Elm::frameImage('alipay_code', '收款二维码', '/' . config('admin.merchant_prefix') . '/setting/uploadPicture?field=alipay_code&type=1')->value($merchant->financial_alipay->alipay_code??'')->modal(['modal' => false])->width('896px')->height('480px'),
|
||||||
|
// ]
|
||||||
|
// ],
|
||||||
|
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
@ -93,24 +94,24 @@ class FinancialRepository extends BaseRepository
|
|||||||
'bank_code' => $data['bank_code'],
|
'bank_code' => $data['bank_code'],
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
case 2:
|
// case 2:
|
||||||
$key = 'financial_wechat' ;
|
// $key = 'financial_wechat' ;
|
||||||
$update = [
|
// $update = [
|
||||||
'name' => $data['name'],
|
// 'name' => $data['name'],
|
||||||
//'idcard' => $data['idcard'],
|
// //'idcard' => $data['idcard'],
|
||||||
'wechat' => $data['wechat'],
|
// 'wechat' => $data['wechat'],
|
||||||
'wechat_code' => $data['wechat_code'],
|
// 'wechat_code' => $data['wechat_code'],
|
||||||
];
|
// ];
|
||||||
break;
|
// break;
|
||||||
case 3:
|
// case 3:
|
||||||
$key = 'financial_alipay' ;
|
// $key = 'financial_alipay' ;
|
||||||
$update = [
|
// $update = [
|
||||||
'name' => $data['name'],
|
// 'name' => $data['name'],
|
||||||
//'idcard' => $data['idcard'],
|
// //'idcard' => $data['idcard'],
|
||||||
'alipay' => $data['alipay'],
|
// 'alipay' => $data['alipay'],
|
||||||
'alipay_code' => $data['alipay_code'],
|
// 'alipay_code' => $data['alipay_code'],
|
||||||
];
|
// ];
|
||||||
break;
|
// break;
|
||||||
}
|
}
|
||||||
return app()->make(MerchantRepository::class)->update($merId,[$key => json_encode($update),'financial_type' => $data['financial_type']]);
|
return app()->make(MerchantRepository::class)->update($merId,[$key => json_encode($update),'financial_type' => $data['financial_type']]);
|
||||||
}
|
}
|
||||||
|
@ -288,4 +288,17 @@ class StoreOrderOther extends BaseController
|
|||||||
$res = $orderRepository->show($id, $this->request->uid());
|
$res = $orderRepository->show($id, $this->request->uid());
|
||||||
return app('json')->success($res);
|
return app('json')->success($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传凭证
|
||||||
|
*/
|
||||||
|
public function upload_voucher($order_id){
|
||||||
|
$find=Db::name('store_order_other')->where('order_id',$order_id)->where('uid', $this->request->uid())->find();
|
||||||
|
if($find){
|
||||||
|
Financial_Operations(98,$order_id,'ADMIN_PAY_SUCCESS_CODE');
|
||||||
|
return app('json')->success('操作成功');
|
||||||
|
}
|
||||||
|
return app('json')->fail('操作失败');
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ class CloudWarehouse extends BaseController
|
|||||||
'status' => 1,
|
'status' => 1,
|
||||||
'is_del' => 0,
|
'is_del' => 0,
|
||||||
'mer_status' => 1,
|
'mer_status' => 1,
|
||||||
'product_type' => 98,
|
'product_type' => 0,
|
||||||
'product_id' => $cloud_product
|
'product_id' => $cloud_product
|
||||||
];
|
];
|
||||||
if (!$cloud_product) {
|
if (!$cloud_product) {
|
||||||
@ -82,7 +82,6 @@ class CloudWarehouse extends BaseController
|
|||||||
$query->whereOr('mer_labels', '')
|
$query->whereOr('mer_labels', '')
|
||||||
->whereOr('mer_labels',',5,');
|
->whereOr('mer_labels',',5,');
|
||||||
})->count();
|
})->count();
|
||||||
|
|
||||||
$products = $this->spuRepository->getApiSearch($where, $page, 10, false, true);
|
$products = $this->spuRepository->getApiSearch($where, $page, 10, false, true);
|
||||||
if ($products['list']) {
|
if ($products['list']) {
|
||||||
$list = $products['list'];
|
$list = $products['list'];
|
||||||
|
@ -66,6 +66,7 @@ return [
|
|||||||
'pay_success_meal' => [\crmeb\listens\pay\MealSuccessListen::class],
|
'pay_success_meal' => [\crmeb\listens\pay\MealSuccessListen::class],
|
||||||
// 'community_address'=>[\app\listener\CommunityAddress::class],
|
// 'community_address'=>[\app\listener\CommunityAddress::class],
|
||||||
'order.paySuccessOrder'=>[\app\listener\paySuccessOrder::class],
|
'order.paySuccessOrder'=>[\app\listener\paySuccessOrder::class],
|
||||||
|
'order.paySuccessOrderOther'=>[\app\listener\paySuccessOrderOther::class],
|
||||||
'order.paySuccess'=>[\app\listener\paySuccess::class],
|
'order.paySuccess'=>[\app\listener\paySuccess::class],
|
||||||
'pay_success_margin'=>[\app\listener\paySuccessMargin::class],
|
'pay_success_margin'=>[\app\listener\paySuccessMargin::class],
|
||||||
'order.sendGoodsCode'=>[\app\listener\SendGoodsCode::class],
|
'order.sendGoodsCode'=>[\app\listener\SendGoodsCode::class],
|
||||||
|
131
app/listener/paySuccessOrderOther.php
Normal file
131
app/listener/paySuccessOrderOther.php
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
<?php
|
||||||
|
declare (strict_types=1);
|
||||||
|
|
||||||
|
namespace app\listener;
|
||||||
|
|
||||||
|
use app\common\dao\store\order\StoreCartDao;
|
||||||
|
use app\common\dao\system\merchant\MerchantDao;
|
||||||
|
use app\common\model\system\merchant\Merchant;
|
||||||
|
use app\common\repositories\store\order\StoreOrderRepository;
|
||||||
|
use app\common\repositories\system\merchant\FinancialRecordRepository;
|
||||||
|
use app\common\repositories\system\merchant\MerchantRepository;
|
||||||
|
use crmeb\utils\DingTalk;
|
||||||
|
use think\facade\Db;
|
||||||
|
use think\facade\Log;
|
||||||
|
/**
|
||||||
|
* 支付后逻辑
|
||||||
|
*/
|
||||||
|
class paySuccessOrderOther
|
||||||
|
{
|
||||||
|
|
||||||
|
public $totalAmount;
|
||||||
|
public $event;
|
||||||
|
public $finance = [];
|
||||||
|
public $streetId;
|
||||||
|
public $financeSn;
|
||||||
|
public $index = 1;
|
||||||
|
public $remain;
|
||||||
|
|
||||||
|
public function handle($event)
|
||||||
|
{
|
||||||
|
Log::info('b到b支付后逻辑22323233');
|
||||||
|
$this->event = $event;
|
||||||
|
$this->finance = [];
|
||||||
|
$this->index = 1;
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
$financialRecordRepository = app()->make(FinancialRecordRepository::class);
|
||||||
|
$this->financeSn = $financialRecordRepository->getSn();
|
||||||
|
$merchant = Merchant::find($event['order']['mer_id']);
|
||||||
|
|
||||||
|
if (!$merchant || $merchant['street_id'] == 0) {
|
||||||
|
throw new \Exception('商户地址不存在', 200);
|
||||||
|
}
|
||||||
|
$this->streetId = $merchant['street_id'];
|
||||||
|
|
||||||
|
$commission_rate = ($event['order']['commission_rate'] / 100);
|
||||||
|
//该笔订单平台总手续费
|
||||||
|
$this->totalAmount = bcmul((string)$event['order']['total_price'], (string)$commission_rate, 2);
|
||||||
|
$this->remain = $this->totalAmount;
|
||||||
|
|
||||||
|
// $typeTownServerId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeTownServer'])->value('mer_type_id');
|
||||||
|
// $typeVillageServerId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeVillageServer'])->value('mer_type_id');
|
||||||
|
// $typeTeamServerId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeTeamServer'])->value('mer_type_id');
|
||||||
|
|
||||||
|
// //镇团队佣金
|
||||||
|
// $this->calculate($typeTownServerId, 'commission_to_town_rate');
|
||||||
|
// //村团队佣金
|
||||||
|
// $this->calculate($typeVillageServerId, 'commission_to_village_rate');
|
||||||
|
// //小组服务团队佣金
|
||||||
|
// $this->calculate($typeTeamServerId, 'commission_to_service_team_rate');
|
||||||
|
|
||||||
|
if ($this->remain > 0) {
|
||||||
|
//平台佣金
|
||||||
|
$this->finance[] = [
|
||||||
|
'order_id' => $this->event['order']['order_id'],
|
||||||
|
'order_sn' => $this->event['order']['order_sn'],
|
||||||
|
'user_info' => $this->event['order']->user->nickname,
|
||||||
|
'user_id' => $this->event['order']['uid'],
|
||||||
|
'financial_type' => 'commission_to_platform',
|
||||||
|
'financial_pm' => 1,
|
||||||
|
'type' => 1,
|
||||||
|
'number' => $this->remain,
|
||||||
|
'mer_id' => 0,
|
||||||
|
'financial_record_sn' => $this->financeSn . $this->index
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($financialRecordRepository->insertAll($this->finance) === false) {
|
||||||
|
throw new \Exception('财务流水保存出错');
|
||||||
|
}
|
||||||
|
Db::commit();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
Log::error('订单分润出错', ['code' => $e->getCode(), 'message' => $e->getMessage(), 'trace' => $e->getTraceAsString()]);
|
||||||
|
DingTalk::exception($e, '订单分润出错');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function calculate($type, $field)
|
||||||
|
{
|
||||||
|
$merId = Db::name('merchant')->where('type_id', $type)
|
||||||
|
->where('street_id', $this->streetId)
|
||||||
|
->where('status', 1)
|
||||||
|
->where('mer_state', 1)
|
||||||
|
->value('mer_id');
|
||||||
|
$rate = systemConfig($field);
|
||||||
|
$typeName = Merchant::TypeMap[$type];
|
||||||
|
if (empty($merId) || $rate <= 0) {
|
||||||
|
Log::info("订单分佣:没有 $typeName 或比例为0");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$financialTypeMap = [
|
||||||
|
'commission_to_town_rate' => 'town',
|
||||||
|
'commission_to_village_rate' => 'village',
|
||||||
|
'commission_to_service_team_rate' => 'service_team',
|
||||||
|
'commission_to_cloud_rate' => 'cloud_warehouse',
|
||||||
|
];
|
||||||
|
$amount = bcmul($this->totalAmount, (string)($rate / 100), 2);
|
||||||
|
if ($amount <= 0) {
|
||||||
|
Log::info("订单分佣:$typeName 佣金为0");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$this->remain = bcsub($this->remain, $amount, 2);
|
||||||
|
$this->finance[] = [
|
||||||
|
'order_id' => $this->event['order']['order_id'],
|
||||||
|
'order_sn' => $this->event['order']['order_sn'],
|
||||||
|
'user_info' => $this->event['order']->user->nickname,
|
||||||
|
'user_id' => $this->event['order']['uid'],
|
||||||
|
'financial_type' => 'commission_to_' . $financialTypeMap[$field],
|
||||||
|
'financial_pm' => 1,
|
||||||
|
'type' => 1,
|
||||||
|
'number' => $amount,
|
||||||
|
'mer_id' => $merId,
|
||||||
|
'financial_record_sn' => $this->financeSn . $this->index
|
||||||
|
];
|
||||||
|
$this->index++;
|
||||||
|
app()->make(MerchantRepository::class)->addLockMoney($merId, 'order', $this->event['order']['order_id'], (float)$amount);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -12,8 +12,10 @@
|
|||||||
namespace crmeb\services;
|
namespace crmeb\services;
|
||||||
|
|
||||||
use app\common\repositories\store\broadcast\BroadcastRoomRepository;
|
use app\common\repositories\store\broadcast\BroadcastRoomRepository;
|
||||||
|
use app\common\repositories\store\order\StoreGroupOrderOtherRepository;
|
||||||
use app\common\repositories\store\order\StoreGroupOrderRepository;
|
use app\common\repositories\store\order\StoreGroupOrderRepository;
|
||||||
use app\common\repositories\store\order\StoreOrderRepository;
|
use app\common\repositories\store\order\StoreOrderRepository;
|
||||||
|
use app\common\repositories\store\order\StoreOtherOrderRepository;
|
||||||
use app\common\repositories\store\order\StoreRefundOrderRepository;
|
use app\common\repositories\store\order\StoreRefundOrderRepository;
|
||||||
use app\common\repositories\store\product\ProductRepository;
|
use app\common\repositories\store\product\ProductRepository;
|
||||||
use app\common\repositories\store\product\ProductTakeRepository;
|
use app\common\repositories\store\product\ProductTakeRepository;
|
||||||
@ -285,9 +287,20 @@ class SmsService
|
|||||||
case 'MERCHANT_CREDIT_BUY_NOTICE':
|
case 'MERCHANT_CREDIT_BUY_NOTICE':
|
||||||
self::sendMerMessage($id, $tempId, ['order_id' => $data['orderId']]);
|
self::sendMerMessage($id, $tempId, ['order_id' => $data['orderId']]);
|
||||||
break;
|
break;
|
||||||
|
//下单通知
|
||||||
case 'ORDER_CREATE':
|
case 'ORDER_CREATE':
|
||||||
self::create()->send($data['phone'], $tempId, ['name' => $data['orderId']]);
|
self::create()->send($data['phone'], $tempId, ['name' => $data['orderId']]);
|
||||||
break;
|
break;
|
||||||
|
//管理员确认收货提醒
|
||||||
|
case 'OTHER_ADMIN_TAKE_DELIVERY_CODE':
|
||||||
|
$order = app()->make(StoreOtherOrderRepository::class)->get($id);
|
||||||
|
if (!$order) return;
|
||||||
|
self::sendMerMessage($order->mer_id, 'ADMIN_TAKE_DELIVERY_CODE', ['order_id' => $order->order_sn]);
|
||||||
|
break;
|
||||||
|
//管理员 支付成功提醒
|
||||||
|
case 'OTHER_ADMIN_PAY_SUCCESS_CODE':
|
||||||
|
self::create()->send($data['phone'], 'ADMIN_PAY_SUCCESS_CODE', ['order_id' => $data['orderId']]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user