更新支付流程

This commit is contained in:
mkm 2024-01-20 15:16:37 +08:00
parent a991fc0789
commit f1a67ff8d7
4 changed files with 109 additions and 71 deletions

View File

@ -314,7 +314,7 @@ class StoreOrderRepository extends BaseRepository
'financial_record_sn' => $financeSn . ($i++) 'financial_record_sn' => $financeSn . ($i++)
]; ];
if($order->source==103){ if ($order->source == 103) {
$_payPrice = $order->procure_price; $_payPrice = $order->procure_price;
$finance[] = [ $finance[] = [
'order_id' => $order->order_id, 'order_id' => $order->order_id,
@ -328,17 +328,45 @@ class StoreOrderRepository extends BaseRepository
'mer_id' => $order->mer_id, 'mer_id' => $order->mer_id,
'financial_record_sn' => $financeSn . ($i++) 'financial_record_sn' => $financeSn . ($i++)
]; ];
//市级供应链
$product_mer_id = Db::name('store_order_product')->where('order_id', $order->order_id)->value('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;
[$_payPrice, $a, $increase] = $merchantRepo->autoMargin($_payPrice, $order, $finance, $financeSn, $i++);
}
$finance[] = [
'order_id' => $order->order_id,
'order_sn' => $order->order_sn,
'user_info' => $groupOrder->user->nickname,
'user_id' => $uid,
'financial_type' => 'supply_chain',
'financial_pm' => 0,
'type' => 1,
'number' => $_payPrice,
'mer_id' => $product_mer_id,
'financial_record_sn' => $financeSn . (($i++)+1)
];
if (!$is_combine) {
app()->make(MerchantRepository::class)->addLockMoney($product_mer_id, 'order', $order->order_id, $_payPrice);
}
}
//计算手续费 //计算手续费
$_order_rate=bcsub($order->pay_price,$_payPrice,2); $_order_rate = bcsub($order->pay_price, $_payPrice, 2);
//计算镇级供应链云仓实际获得金额 //计算镇级供应链云仓实际获得金额
if($_order_rate>0){ if ($_order_rate > 0) {
$commission_rate = bcdiv(3,100,2); $commission_rate = bcdiv(3, 100, 2);
$_payPrice = bcmul($_order_rate, $commission_rate, 2); $_payPrice = bcmul($_order_rate, $commission_rate, 2);
}else{ } else {
$_payPrice=0; $_payPrice = 0;
} }
}else{ } else {
$_payPrice = $order->pay_price; $_payPrice = $order->pay_price;
$_order_rate = 0; $_order_rate = 0;
@ -368,7 +396,7 @@ class StoreOrderRepository extends BaseRepository
if (!$presell) { if (!$presell) {
if ($order['commission_rate'] > 0 ||$order->source==103) { if ($order['commission_rate'] > 0 || $order->source == 103) {
$finance[] = [ $finance[] = [
'order_id' => $order->order_id, 'order_id' => $order->order_id,
'order_sn' => $order->order_sn, 'order_sn' => $order->order_sn,
@ -390,6 +418,20 @@ class StoreOrderRepository extends BaseRepository
$merchantRepo->forceMargin = false; $merchantRepo->forceMargin = false;
[$_payPrice, $finance, $increase] = $merchantRepo->autoMargin($_payPrice, $order, $finance, $financeSn, $i++); [$_payPrice, $finance, $increase] = $merchantRepo->autoMargin($_payPrice, $order, $finance, $financeSn, $i++);
} }
if ($order->source == 103) {
$finance[] = [
'order_id' => $order->order_id,
'order_sn' => $order->order_sn,
'user_info' => $groupOrder->user->nickname,
'user_id' => $uid,
'financial_type' => 'commission_to_cloud_warehouse',
'financial_pm' => 0,
'type' => 1,
'number' => $_payPrice,
'mer_id' => $order->mer_id,
'financial_record_sn' => $financeSn . ($i++)
];
} else {
$finance[] = [ $finance[] = [
'order_id' => $order->order_id, 'order_id' => $order->order_id,
'order_sn' => $order->order_sn, 'order_sn' => $order->order_sn,
@ -402,6 +444,8 @@ class StoreOrderRepository extends BaseRepository
'mer_id' => $order->mer_id, 'mer_id' => $order->mer_id,
'financial_record_sn' => $financeSn . ($i++) 'financial_record_sn' => $financeSn . ($i++)
]; ];
}
// if ($order->platform_coupon_price > 0) { // if ($order->platform_coupon_price > 0) {
// $finance[] = [ // $finance[] = [
@ -469,23 +513,21 @@ class StoreOrderRepository extends BaseRepository
if (count($groupOrder['give_coupon_ids']) > 0) if (count($groupOrder['give_coupon_ids']) > 0)
$groupOrder['give_coupon_ids'] = app()->make(StoreCouponRepository::class)->getGiveCoupon($groupOrder['give_coupon_ids'])->column('coupon_id'); $groupOrder['give_coupon_ids'] = app()->make(StoreCouponRepository::class)->getGiveCoupon($groupOrder['give_coupon_ids'])->column('coupon_id');
$groupOrder->save(); $groupOrder->save();
$group_id=0; $group_id = 0;
if($order->activity_type==98){ if ($order->activity_type == 98) {
$group_id=Db::name('system_group')->where('group_key','city_operations')->value('group_id'); $group_id = Db::name('system_group')->where('group_key', 'city_operations')->value('group_id');
}else{ } else {
$group_id=Db::name('system_group')->where('group_key','town_operation')->value('group_id'); $group_id = Db::name('system_group')->where('group_key', 'town_operation')->value('group_id');
} }
if($group_id){ if ($group_id) {
$group_value=Db::name('system_group_data')->where('group_id',$group_id)->column('value'); $group_value = Db::name('system_group_data')->where('group_id', $group_id)->column('value');
if($group_value){ if ($group_value) {
foreach($group_value as $k=>$v){ foreach ($group_value as $k => $v) {
$phone=json_decode($v,true); $phone = json_decode($v, true);
Queue::push(SendSmsJob::class, ['tempId' => 'ORDER_CREATE', 'phone' => $phone['phone'],'orderId'=>$order->order_id,'id'=>0]);//短信通知 Queue::push(SendSmsJob::class, ['tempId' => 'ORDER_CREATE', 'phone' => $phone['phone'], 'orderId' => $order->order_id, 'id' => 0]); //短信通知
} }
} }
} }
}); });
if (count($groupOrder['give_coupon_ids']) > 0) { if (count($groupOrder['give_coupon_ids']) > 0) {
@ -568,7 +610,7 @@ class StoreOrderRepository extends BaseRepository
} }
} }
public function cartByPrice($cart,$type=0) public function cartByPrice($cart, $type = 0)
{ {
if ($cart['product_type'] == '2') { if ($cart['product_type'] == '2') {
return $cart['productPresellAttr']['presell_price']; return $cart['productPresellAttr']['presell_price'];
@ -578,10 +620,10 @@ class StoreOrderRepository extends BaseRepository
return $cart['activeSku']['active_price']; return $cart['activeSku']['active_price'];
// 更新调货价格 // 更新调货价格
} else if ($cart['product_type'] == '98') { } else if ($cart['product_type'] == '98') {
if($type==1){ if ($type == 1) {
return $cart['productAttr']['procure_price']; return $cart['productAttr']['procure_price'];
}else{ } else {
if (in_array($cart['source'],[9,10,11,12,13])) { if (in_array($cart['source'], [9, 10, 11, 12, 13])) {
return $cart['productAttr']['procure_price']; return $cart['productAttr']['procure_price'];
} else { } else {
return $cart['productAttr']['price']; return $cart['productAttr']['price'];
@ -601,9 +643,9 @@ class StoreOrderRepository extends BaseRepository
return $cart['productAttr']['price']; return $cart['productAttr']['price'];
} }
} else { } else {
if($type==0){ if ($type == 0) {
return $cart['productAttr']['price']; return $cart['productAttr']['price'];
}else{ } else {
return $cart['productAttr']['procure_price']; return $cart['productAttr']['procure_price'];
} }
} }
@ -656,7 +698,7 @@ class StoreOrderRepository extends BaseRepository
* @author xaboy * @author xaboy
* @day 2020/6/10 * @day 2020/6/10
*/ */
public function userOrderNumber(int $uid, $product_type = 0,$source=2) public function userOrderNumber(int $uid, $product_type = 0, $source = 2)
{ {
//activity_type0普通订单 98采购订单 99委托商品 //activity_type0普通订单 98采购订单 99委托商品
//$noPay = app()->make(StoreGroupOrderRepository::class)->orderNumber($uid, $product_type); //$noPay = app()->make(StoreGroupOrderRepository::class)->orderNumber($uid, $product_type);
@ -664,10 +706,10 @@ class StoreOrderRepository extends BaseRepository
if ($product_type == 98 || $product_type == 99) { if ($product_type == 98 || $product_type == 99) {
$isUser = 0; $isUser = 0;
} }
$where['activity_type']=$product_type; $where['activity_type'] = $product_type;
if($source==103){ if ($source == 103) {
$where['activity_type']=[0,98]; $where['activity_type'] = [0, 98];
$where['source']=[0,2,103]; $where['source'] = [0, 2, 103];
} }
$noComment = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(4))->where($where)->where('StoreOrder.is_del', 0)->count(); $noComment = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(4))->where($where)->where('StoreOrder.is_del', 0)->count();
$noPay = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(1))->whereRaw("(StoreOrder.paid=0 and StoreOrder.pay_type!=8) or (StoreOrder.paid=1 and StoreOrder.pay_type=8 and StoreOrder.status=2)")->where($where)->where('StoreOrder.is_del', 0)->count(); $noPay = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(1))->whereRaw("(StoreOrder.paid=0 and StoreOrder.pay_type!=8) or (StoreOrder.paid=1 and StoreOrder.pay_type=8 and StoreOrder.status=2)")->where($where)->where('StoreOrder.is_del', 0)->count();
@ -1516,10 +1558,10 @@ class StoreOrderRepository extends BaseRepository
] ]
); );
if (!$res) throw new ValidateException('数据不存在'); if (!$res) throw new ValidateException('数据不存在');
if(in_array($res['source'],[13])){ if (in_array($res['source'], [13])) {
$res['bank_info']=Db::name('merchant_intention')->where('status',1)->where('uid',$res['uid'])->field('company_name,bank_username,bank_opening,bank_code')->find(); $res['bank_info'] = Db::name('merchant_intention')->where('status', 1)->where('uid', $res['uid'])->field('company_name,bank_username,bank_opening,bank_code')->find();
}else{ } else {
$res['bank_info']=[]; $res['bank_info'] = [];
} }
$res['integral'] = (int)$res['integral']; $res['integral'] = (int)$res['integral'];
@ -2540,10 +2582,10 @@ class StoreOrderRepository extends BaseRepository
$attr = []; $attr = [];
$arr = []; $arr = [];
if(!$attr_one){ if (!$attr_one) {
$attr_one[] = '规格'; $attr_one[] = '规格';
} }
if(!$attr_two){ if (!$attr_two) {
$attr_two[] = '默认'; $attr_two[] = '默认';
} }
foreach ($attr_one as $key => $value) { foreach ($attr_one as $key => $value) {
@ -2604,9 +2646,9 @@ class StoreOrderRepository extends BaseRepository
$detail = $attr; $detail = $attr;
/**查询平台分类 */ /**查询平台分类 */
$cate_id_one = Db::name('store_category')->where('is_show',1)->where('mer_id', 0)->where('cate_name', $datum['value']['cate_id_one'])->value('store_category_id'); $cate_id_one = Db::name('store_category')->where('is_show', 1)->where('mer_id', 0)->where('cate_name', $datum['value']['cate_id_one'])->value('store_category_id');
if ($cate_id_one) { if ($cate_id_one) {
$cate_id_two = Db::name('store_category')->where('is_show',1)->where('mer_id', 0)->where('pid',$cate_id_one)->where('cate_name', $datum['value']['cate_id_two'])->value('store_category_id'); $cate_id_two = Db::name('store_category')->where('is_show', 1)->where('mer_id', 0)->where('pid', $cate_id_one)->where('cate_name', $datum['value']['cate_id_two'])->value('store_category_id');
if ($cate_id_two) { if ($cate_id_two) {
$cate_id = $cate_id_two; $cate_id = $cate_id_two;
} }
@ -2710,7 +2752,7 @@ class StoreOrderRepository extends BaseRepository
"ot_price" => $datum['value']['price'], "ot_price" => $datum['value']['price'],
"svip_price" => null, "svip_price" => null,
"procure_price" => $procure_price, "procure_price" => $procure_price,
"stock" =>$datum['value']['stock']??1, "stock" => $datum['value']['stock'] ?? 1,
"bar_code" => (int)$datum['value']['bar_code'], "bar_code" => (int)$datum['value']['bar_code'],
"weight" => 0, "weight" => 0,
"volume" => 0, "volume" => 0,
@ -2738,7 +2780,6 @@ class StoreOrderRepository extends BaseRepository
} }
} }
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
$datas['product_id'] = $product_id ?? 0; $datas['product_id'] = $product_id ?? 0;
$datas['mer_id'] = $merId; $datas['mer_id'] = $merId;
@ -2766,7 +2807,7 @@ class StoreOrderRepository extends BaseRepository
if (!empty($datum['value']['procure_price'])) { if (!empty($datum['value']['procure_price'])) {
$procure_price = $datum['value']['procure_price']; $procure_price = $datum['value']['procure_price'];
} }
$stock=$datum['value']['stock']??1; $stock = $datum['value']['stock'] ?? 1;
$attrValue['stock'] = $stock; $attrValue['stock'] = $stock;
$unique = app(ProductRepository::class)->setUnique($find['product_id'], $datum['value']['bar_code'], $product_type); $unique = app(ProductRepository::class)->setUnique($find['product_id'], $datum['value']['bar_code'], $product_type);
$attrValue['unique'] = $unique; $attrValue['unique'] = $unique;
@ -2779,7 +2820,7 @@ class StoreOrderRepository extends BaseRepository
$attrValue['price'] = $datum['value']['price']; $attrValue['price'] = $datum['value']['price'];
$attrValue['procure_price'] = $procure_price; $attrValue['procure_price'] = $procure_price;
$attrValue["image"] = "https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/oa_app/23565656.png"; $attrValue["image"] = "https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/oa_app/23565656.png";
Db::name('store_product')->where('product_id',$find['product_id'])->update(['spec_type'=>1,'stock'=>Db::raw('stock+'.$stock)]); Db::name('store_product')->where('product_id', $find['product_id'])->update(['spec_type' => 1, 'stock' => Db::raw('stock+' . $stock)]);
Db::name('store_product_attr_value')->insert($attrValue); Db::name('store_product_attr_value')->insert($attrValue);
} }
/** /**

View File

@ -714,13 +714,10 @@ class FinancialRecordRepository extends BaseRepository
//平台手续费 = order_charge + 预售手续费 presell_charge - 平台退给商户的手续费 refund_charge //平台手续费 = order_charge + 预售手续费 presell_charge - 平台退给商户的手续费 refund_charge
$number_1 = bcsub($data['number_order_charge'], $data['number_charge'], 2); $number_1 = bcsub($data['number_order_charge'], $data['number_charge'], 2);
if($data['number_supply_chain']>0){ if($data['number_supply_chain']>0){
$financialType = ['order_true']; $financialType = ['commission_to_cloud_warehouse'];
$where['type']=2; [$data['count_commission_to_cloud_warehouse'], $data['number_commission_to_cloud_warehouse']] = $this->dao->getDataByType($type, $where, $date, $financialType);
$where['mer_id']=$where['is_mer'];
unset($where['is_mer']);
[$data['count_order'], $data['number_order']] = $this->dao->getDataByType($type, $where, $date, $financialType);
$number_1=bcadd($number_1, $data['number_supply_chain'], 2); $number_1=bcadd($number_1, $data['number_supply_chain'], 2);
$number_1=bcsub( $number_1, $data['number_order'], 2); $number_1=bcsub( $number_1, $data['number_commission_to_cloud_warehouse'], 2);
} }
//退回收入 refund_order + 退回佣金 //退回收入 refund_order + 退回佣金

View File

@ -687,9 +687,9 @@ class MerchantRepository extends BaseRepository
public function autoMargin($income, $order, $finance, $financeSn, $index = 0) public function autoMargin($income, $order, $finance, $financeSn, $index = 0)
{ {
$merchant = Merchant::find($this->merId); $merchant = Merchant::find($this->merId);
$margin_type = Db::name('MerchantType')->where('mer_type_id', $merchant['type_id'])->value('margin'); // $margin_type = Db::name('MerchantType')->where('mer_type_id', $merchant['type_id'])->value('margin');
//商户押金大于支付押金 或者forceMargin==false 直接返回 不计算押金 //商户押金大于支付押金 或者forceMargin==false 直接返回 不计算押金
if ($merchant['paid_margin']>= $margin_type|| ($this->forceMargin === false && $merchant['auto_margin_rate'] == 0)) { if ($merchant['paid_margin']>= $merchant['margin']|| ($this->forceMargin === false && $merchant['auto_margin_rate'] == 0)) {
return [$income, $finance, false]; return [$income, $finance, false];
} }
$rate = $this->forceMargin ? 100 : $merchant['auto_margin_rate']; $rate = $this->forceMargin ? 100 : $merchant['auto_margin_rate'];
@ -712,7 +712,7 @@ class MerchantRepository extends BaseRepository
'mer_id' => $this->merId, 'mer_id' => $this->merId,
'financial_record_sn' => $financeSn . $index 'financial_record_sn' => $financeSn . $index
]; ];
if(bcadd($merchant['paid_margin'],$margin)>=$margin_type){ if(bcadd($merchant['paid_margin'],$margin)>=$merchant['margin']){
$is_margin=10; $is_margin=10;
}else{ }else{
$is_margin=1; $is_margin=1;

View File

@ -366,8 +366,8 @@ class ExcelService
'commission_to_village_refund' => '退回平台佣金', 'commission_to_village_refund' => '退回平台佣金',
'commission_to_town_refund' => '退回平台佣金', 'commission_to_town_refund' => '退回平台佣金',
'auto_margin_refund' => '退回押金', 'auto_margin_refund' => '退回押金',
'commission_to_entry_merchant' => '订单平台佣金', 'commission_to_entry_merchant' => '订单平台佣金',//入口店铺佣金
'commission_to_cloud_warehouse' => '订单平台佣金', 'commission_to_cloud_warehouse' => '订单平台佣金',//云仓佣金
'commission_to_entry_merchant_refund' => '退回平台佣金', 'commission_to_entry_merchant_refund' => '退回平台佣金',
'commission_to_cloud_warehouse_refund' => '退回平台佣金', 'commission_to_cloud_warehouse_refund' => '退回平台佣金',
'first_order_commission' => '首单拉新', 'first_order_commission' => '首单拉新',