|
@@ -185,7 +185,7 @@ class refill_order_manualControl extends SystemControl
|
|
|
}
|
|
|
}
|
|
|
elseif (in_array($oper_type, ['success', 'cancel', 'buyback'])) {
|
|
|
- $this->manual_record($orders, $oper_type, $order_ids, $_GET['bz']);
|
|
|
+ $this->manual_record($orders, $oper_type, $order_ids, $_GET);
|
|
|
}
|
|
|
else {
|
|
|
showMessage('手动操作类型错误');
|
|
@@ -193,10 +193,10 @@ class refill_order_manualControl extends SystemControl
|
|
|
showMessage('操作成功');
|
|
|
}
|
|
|
|
|
|
- private function manual_record($orders, $oper_type, $order_ids, $bz)
|
|
|
+ private function manual_record($orders, $oper_type, $order_ids, $input)
|
|
|
{
|
|
|
$admininfo = $this->getAdminInfo();
|
|
|
- $bz = empty($bz) ? '' : $bz;
|
|
|
+ $bz = empty($input['bz']) ? '' : $input['bz'];
|
|
|
|
|
|
$buyback_ids = function ($order_ids, $oper_type) {
|
|
|
$buybacks = Model('refill_buyback')->getBuyBackList(['order_id' => ['in', $order_ids], 'manual_type' => $oper_type]);
|
|
@@ -220,14 +220,21 @@ class refill_order_manualControl extends SystemControl
|
|
|
|
|
|
if($oper_type == 'buyback')
|
|
|
{
|
|
|
+ $merge = $input['merge'];
|
|
|
$mchids = array_column($orders, 'mchid');
|
|
|
$mchids = $this->unique_array($mchids);
|
|
|
+ if($merge > 0 && count($mchids) > 1) {
|
|
|
+ showMessage('下游机构多家时,返销记录不可合并');
|
|
|
+ }
|
|
|
$merchant_list = $this->merchants(['mchid' => ['in', $mchids]]);
|
|
|
foreach ($merchant_list as $merchant) {
|
|
|
$merchants[$merchant['mchid']] = $merchant;
|
|
|
}
|
|
|
$store_ids = array_column($orders, 'store_id');
|
|
|
$store_ids = $this->unique_array($store_ids);
|
|
|
+ if($merge > 0 && count($store_ids) > 1) {
|
|
|
+ showMessage('上游通道多家时,返销记录不可合并');
|
|
|
+ }
|
|
|
$provider_list = $this->providers(['refill_provider.store_id' => ['in', $store_ids]]);
|
|
|
foreach ($provider_list as $provider) {
|
|
|
$providers[$provider['store_id']] = $provider;
|
|
@@ -242,6 +249,8 @@ class refill_order_manualControl extends SystemControl
|
|
|
$cur_time = time();
|
|
|
if($oper_type == 'buyback')
|
|
|
{
|
|
|
+ $refill_evidence = [];
|
|
|
+ $provider_amount = [];
|
|
|
foreach ($orders as $order)
|
|
|
{
|
|
|
$order_id = intval($order['order_id']);
|
|
@@ -273,15 +282,37 @@ class refill_order_manualControl extends SystemControl
|
|
|
if($ret)
|
|
|
{
|
|
|
$merchant_bz = "机构:{$mchid},订单号:{$order['mch_order']},卡号:{$order['card_no']},返销退款:{$order['mch_amount']}";
|
|
|
- $this->ct_refill_evidence(['mch_amount' => $order['mch_amount'], 'bz' => $merchant_bz], $merchant_info, $cur_time, $admininfo);
|
|
|
$this->credit_save_money($order['mch_amount'], 'add', $buyer_id, $merchant_bz);
|
|
|
+ if ($merge > 0) {
|
|
|
+ $refill_evidence['mchid'] = $mchid;
|
|
|
+ if (!array_key_exists('mch_amount', $refill_evidence)) {
|
|
|
+ $refill_evidence['mch_amount'] = $order['mch_amount'];
|
|
|
+ $refill_evidence['count'] = 1;
|
|
|
+ } else {
|
|
|
+ $refill_evidence['mch_amount'] += $order['mch_amount'];
|
|
|
+ $refill_evidence['count'] += 1;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $this->ct_refill_evidence(['mch_amount' => $order['mch_amount'], 'bz' => $merchant_bz], $merchant_info, $cur_time, $admininfo);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if($ret)
|
|
|
{
|
|
|
$provider_bz = "通道:{$store_id},椰子单号:{$order['order_sn']},卡号:{$order['card_no']},返销退款:{$order['channel_amount']}";
|
|
|
- $this->ct_provider_amount(['channel_amount' => $order['channel_amount']], $provider_info, $cur_time, $admininfo);
|
|
|
$this->credit_save_money($order['channel_amount'], 'add', $account_id, $provider_bz);
|
|
|
+ if($merge > 0) {
|
|
|
+ $provider_amount['store_id'] = $store_id;
|
|
|
+ if (!array_key_exists('channel_amount', $provider_amount)) {
|
|
|
+ $provider_amount['channel_amount'] = $order['channel_amount'];
|
|
|
+ $provider_amount['count'] = 1;
|
|
|
+ } else {
|
|
|
+ $provider_amount['channel_amount'] += $order['channel_amount'];
|
|
|
+ $provider_amount['count'] += 1;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $this->ct_provider_amount(['channel_amount' => $order['channel_amount']], $provider_info, $cur_time, $admininfo);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$trans->commit();
|
|
@@ -291,6 +322,15 @@ class refill_order_manualControl extends SystemControl
|
|
|
Log::record("manual_record err: {$e->getMessage()}", Log::ERR);
|
|
|
}
|
|
|
}
|
|
|
+ if(!empty($refill_evidence)) {
|
|
|
+ $merchant_bz = "机构:{$mchid},共返销单数:{$refill_evidence['count']},返销退款总金额:{$refill_evidence['mch_amount']}";
|
|
|
+ $merchant_info = $merchants[$refill_evidence['mchid']];
|
|
|
+ $this->ct_refill_evidence(['mch_amount' => $refill_evidence['mch_amount'], 'bz' => $merchant_bz], $merchant_info, $cur_time, $admininfo);
|
|
|
+ }
|
|
|
+ if(!empty($provider_amount)) {
|
|
|
+ $provider_info = $providers[$store_id];
|
|
|
+ $this->ct_provider_amount(['channel_amount' => $provider_amount['channel_amount']], $provider_info, $cur_time, $admininfo);
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|