订单退款,扣除劳务费
This commit is contained in:
parent
a135427f53
commit
bce9d447c1
|
@ -20,6 +20,7 @@ use app\common\logic\BaseLogic;
|
||||||
use app\common\model\contract\Contract;
|
use app\common\model\contract\Contract;
|
||||||
use app\common\model\dict\DictData;
|
use app\common\model\dict\DictData;
|
||||||
use app\common\model\user\User;
|
use app\common\model\user\User;
|
||||||
|
use app\common\model\user\UserAccountLog;
|
||||||
use app\common\service\ConfigService;
|
use app\common\service\ConfigService;
|
||||||
use think\facade\Config;
|
use think\facade\Config;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
@ -307,4 +308,20 @@ class UserLogic extends BaseLogic
|
||||||
{
|
{
|
||||||
return Db::name('user_invite_first_order_log')->insert(['user_id' => $userId, 'order_money' => bcdiv($orderMoney, 100, 2), 'order_no' => $orderNo, 'create_time' => time()]);
|
return Db::name('user_invite_first_order_log')->insert(['user_id' => $userId, 'order_money' => bcdiv($orderMoney, 100, 2), 'order_no' => $orderNo, 'create_time' => time()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function handleProfitRefund($orderNo)
|
||||||
|
{
|
||||||
|
$userAccountLog = UserAccountLog::where('source_sn', $orderNo)->where('action', 1)->find();
|
||||||
|
if ($userAccountLog) {
|
||||||
|
$money = $userAccountLog['change_amount'];
|
||||||
|
$arr = [$userAccountLog['user_id'], AccountLogEnum::UM_DEC_ORDER_REFUND, AccountLogEnum::DEC, $money, $orderNo, '订单退款' . '扣除劳务费' . $money . '元', ['company_id' => 0, 'proportion' => 0], 1];
|
||||||
|
self::decrUserAccountLog($arr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function decrUserAccountLog($data)
|
||||||
|
{
|
||||||
|
User::where('id', $data[0])->update(['user_money'=>Db::raw('user_money-' . $data[3])]);
|
||||||
|
return AccountLogLogic::add($data[0], $data[1], $data[2], $data[3], $data[4], $data[5], $data[6], $data[7]);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -5,6 +5,7 @@ namespace app\api\controller;
|
||||||
use app\adminapi\logic\user\UserLogic;
|
use app\adminapi\logic\user\UserLogic;
|
||||||
use app\common\logic\ShopRequestLogic;
|
use app\common\logic\ShopRequestLogic;
|
||||||
use app\common\model\user\User;
|
use app\common\model\user\User;
|
||||||
|
use app\common\model\user\UserAccountLog;
|
||||||
use think\exception\ValidateException;
|
use think\exception\ValidateException;
|
||||||
use think\facade\Log;
|
use think\facade\Log;
|
||||||
|
|
||||||
|
@ -13,7 +14,7 @@ use think\facade\Log;
|
||||||
*/
|
*/
|
||||||
class ShopCallController extends BaseApiController
|
class ShopCallController extends BaseApiController
|
||||||
{
|
{
|
||||||
public array $notNeedLogin = ['user_first_order_share_profit', 'user_order_share_profit'];
|
public array $notNeedLogin = ['user_first_order_share_profit', 'user_order_share_profit', 'handleRefund'];
|
||||||
public string $apiSecret = '';
|
public string $apiSecret = '';
|
||||||
|
|
||||||
public function initialize()
|
public function initialize()
|
||||||
|
@ -229,4 +230,24 @@ class ShopCallController extends BaseApiController
|
||||||
Log::info('镇合伙人,配送员分润通知商城返回:'.json_encode($res));
|
Log::info('镇合伙人,配送员分润通知商城返回:'.json_encode($res));
|
||||||
return $this->success('成功', ['user_id' => $userSelf['id'], 'account' => $userSelf['account'], 'user_profit' => bcmul($orderMoney, $proportion, 2)]);
|
return $this->success('成功', ['user_id' => $userSelf['id'], 'account' => $userSelf['account'], 'user_profit' => bcmul($orderMoney, $proportion, 2)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 退款扣除佣金
|
||||||
|
public function handleRefund()
|
||||||
|
{
|
||||||
|
$params = $this->request->param();
|
||||||
|
$timestamp = $params['timestamp'];
|
||||||
|
$iv = substr(md5($this->apiSecret.$timestamp), 5, 16);
|
||||||
|
// $secretData = encrypt($params, $this->apiSecret, $iv); halt($secretData);
|
||||||
|
// halt($secretData);
|
||||||
|
$requestDatas = decrypt($params['data'], $this->apiSecret, $iv);
|
||||||
|
Log::info('镇合伙人,配送员分润请求参数:'.json_encode($requestDatas));
|
||||||
|
if (null === $requestDatas) {
|
||||||
|
return $this->fail('非法访问,解析失败');
|
||||||
|
}
|
||||||
|
$orderNo = $requestDatas['data']['order_sn']; // 订单金额
|
||||||
|
|
||||||
|
UserLogic::handleProfitRefund($orderNo);
|
||||||
|
|
||||||
|
return $this->success('成功');
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -48,6 +48,7 @@ class AccountLogEnum
|
||||||
const UM_DEC_ADMIN = 100;
|
const UM_DEC_ADMIN = 100;
|
||||||
const UM_DEC_RECHARGE_REFUND = 101;
|
const UM_DEC_RECHARGE_REFUND = 101;
|
||||||
const UM_DEC_WITHDRAW = 102; // 提现
|
const UM_DEC_WITHDRAW = 102; // 提现
|
||||||
|
const UM_DEC_ORDER_REFUND = 103; // 订单退狂
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户余额增加类型
|
* 用户余额增加类型
|
||||||
|
@ -64,7 +65,8 @@ class AccountLogEnum
|
||||||
const UM_DEC = [
|
const UM_DEC = [
|
||||||
self::UM_DEC_ADMIN,
|
self::UM_DEC_ADMIN,
|
||||||
self::UM_DEC_RECHARGE_REFUND,
|
self::UM_DEC_RECHARGE_REFUND,
|
||||||
self::UM_DEC_WITHDRAW
|
self::UM_DEC_WITHDRAW,
|
||||||
|
self::UM_DEC_ORDER_REFUND
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue