订单根据仓库自动拆单,订单售后新增时限

This commit is contained in:
devil 2020-07-24 15:11:13 +08:00
parent 7ead9573c0
commit e9e7a001a9
17 changed files with 451 additions and 335 deletions

View File

@ -24,6 +24,16 @@
<input type="text" name="{{$data.home_order_aftersale_return_goods_address.only_tag}}" placeholder="{{$data.home_order_aftersale_return_goods_address.name}}" data-validation-message="{{$data.home_order_aftersale_return_goods_address.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.home_order_aftersale_return_goods_address.value}}"{{/if}} />
</div>
<div class="am-form-group">
<label>{{$data.home_order_aftersale_return_launch_day.name}}<span class="am-form-group-label-tips">{{$data.home_order_aftersale_return_launch_day.describe}}</span></label>
<div class="am-input-group am-input-group-sm">
<input type="number" min="0" name="{{$data.home_order_aftersale_return_launch_day.only_tag}}" placeholder="{{$data.home_order_aftersale_return_launch_day.name}}" data-validation-message="{{$data.home_order_aftersale_return_launch_day.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.home_order_aftersale_return_launch_day.value}}"{{/if}} />
<span class="am-input-group-btn">
<button class="am-btn am-btn-default" type="button"></button>
</span>
</div>
</div>
<div class="am-form-group am-form-group-refreshing">
<input type="hidden" name="nav_type" value="{{$nav_type}}" />
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block" data-am-loading="{loadingText:'处理中...'}">保存</button>

View File

@ -342,7 +342,7 @@
{{$goods.stock}} {{$goods.inventory_unit}}
</td>
<td class="total-price am-hide-sm-only">
<strong>{{$price_symbol}}</strong><strong class="total-price-content">{{$goods.total_price}}</strong>
<span>{{$price_symbol}}</span><strong class="total-price-content">{{$goods.total_price}}</strong>
</td>
</tr>
{{/foreach}}
@ -377,9 +377,9 @@
{{/php}}
<!-- 扩展展示数据 -->
{{if !empty($v['extension_data'])}}
{{if !empty($v['order_base']['extension_data'])}}
<ul class="buy-extension-data am-padding-xs am-margin-bottom-sm">
{{foreach $v['extension_data'] as $ext}}
{{foreach $v['order_base']['extension_data'] as $ext}}
<li>
<span class="extension-items-name">{{$ext.name}}</span>
<span class="am-fr extension-items-tips">{{$ext.tips}}</span>
@ -390,9 +390,12 @@
<!-- 含运费小计 -->
<div class="buy-point-discharge am-text-right">
<p>
合计 <span class="price"><strong>{{$price_symbol}}</strong><strong class="total-price-content am-text-lg">{{$v.items_total_price}}</strong></span>
</p>
{{if $v['order_base']['total_price'] neq $v['order_base']['actual_price']}}
<span class="original-price am-margin-right-xs">{{$price_symbol}}{{$v.order_base.total_price}}</span>
{{/if}}
<span>
合计 <span class="price"><span>{{$price_symbol}}</span><strong class="total-price-content line-price am-text-sm">{{$v.order_base.actual_price}}</strong></span>
</span>
</div>
</div>
</div>
@ -458,10 +461,9 @@
<div class="pay-confirm">
<div class="box">
<div class="base-real-pay">
<em>实付款</em>
<em>实付款 :</em>
<span class="price">
<strong>{{$price_symbol}}</strong>
<strong class="nav-total-price">{{$base.actual_price}}</strong>
<span>{{$price_symbol}}</span><strong class="nav-total-price">{{$base.actual_price}}</strong>
</span>
</div>
@ -469,7 +471,7 @@
{{if in_array($common_site_type, [0,2,4]) and !empty($base['address'])}}
<div class="pay-address">
<div class="buy-footer-address">
<span class="buy-line-title">联系人</span>
<span class="buy-line-title">联系人 :</span>
<span class="buy-user">
{{if !empty($base['address'])}}
{{$base.address.name}}
@ -486,7 +488,7 @@
</span>
</div>
<div class="buy-footer-address">
<span class="buy-line-title buy-line-title-type">地址</span>
<span class="buy-line-title buy-line-title-type">地址 :</span>
<span class="buy-address-detail">
{{if !empty($base['address'])}}
{{$base.address.province_name}} {{$base.address.city_name}} {{$base.address.county_name}} {{$base.address.address}}

View File

@ -192,15 +192,15 @@
{{/if}}
</td>
<td class="row-number">
<a href="{{:MyUrl('index/orderaftersale/detail', ['oid'=>$order['id'], 'did'=>$goods['id']])}}" target="_blank">
{{if !empty($goods['orderaftersale_btn_text'])}}
{{if ($order['is_can_launch_aftersale'] eq 1 or !empty($goods['orderaftersale'])) and !empty($goods['orderaftersale_btn_text'])}}
<a href="{{:MyUrl('index/orderaftersale/detail', ['oid'=>$order['id'], 'did'=>$goods['id']])}}" target="_blank">
{{if empty($goods['orderaftersale'])}}
{{$goods.orderaftersale_btn_text}}
{{else /}}
<span class="{{if $goods['orderaftersale']['status'] eq 3}}am-text-success{{else /}}am-text-secondary{{/if}}">{{$goods.orderaftersale_btn_text}}</span>
{{/if}}
{{/if}}
</a>
</a>
{{/if}}
</td>
{{if $keys eq 0}}
<td class="row-total-price am-hide-sm-only" rowspan="{{$order.items_count}}">

View File

@ -712,35 +712,60 @@ class BuyService
}
// 订单拆分
$order_split = OrderSplitService::Run(['goods'=>$goods, 'params'=>$params]);
$order_split = OrderSplitService::Run([
'site_model' => $site_model,
'common_site_type' => $common_site_type,
'address' => $address,
'extraction_address' => $extraction_address,
'goods' => $goods,
'params' => $params,
]);
if($order_split['code'] != 0)
{
return $order_split;
}
// 商品/基础信息
$total_price = empty($goods) ? 0 : array_sum(array_column($goods, 'total_price'));
// 订单总计基础信息字段处理
$base_fields = [
'total_price' => 0,
'actual_price' => 0,
'preferential_price' => 0,
'increase_price' => 0,
'goods_count' => 0,
'spec_weight_total' => 0,
'buy_count' => 0,
];
if(!empty($order_split['data']))
{
$order_base = array_column($order_split['data'], 'order_base');
foreach($base_fields as $field=>$value)
{
$base_fields[$field] = array_sum(array_column($order_base, $field));
}
}
// 订单总计基础信息组合
$base = [
// 总价
'total_price' => $total_price,
'total_price' => $base_fields['total_price'],
// 订单实际支付金额(已减去优惠金额, 已加上增加金额)
'actual_price' => $total_price,
'actual_price' => $base_fields['actual_price'],
// 优惠金额
'preferential_price' => 0.00,
'preferential_price' => $base_fields['preferential_price'],
// 增加金额
'increase_price' => 0.00,
'increase_price' => $base_fields['increase_price'],
// 商品数量
'goods_count' => count($goods),
'goods_count' => $base_fields['goods_count'],
// 规格重量总计
'spec_weight_total' => empty($goods) ? 0 : array_sum(array_map(function($v) {return $v['spec_weight']*$v['stock'];}, $goods)),
'spec_weight_total' => $base_fields['spec_weight_total'],
// 购买总数
'buy_count' => empty($goods) ? 0 : array_sum(array_column($goods, 'stock')),
'buy_count' => $base_fields['buy_count'],
// 默认地址
'address' => $address,
@ -766,7 +791,7 @@ class BuyService
$ret = HookReturnHandle(Hook::listen($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'params' => &$params,
'params' => $params,
'data' => &$result,
]));
if(isset($ret['code']) && $ret['code'] != 0)
@ -774,7 +799,7 @@ class BuyService
return $ret;
}
// 返回数据再次处理,防止插件处理不够完善
// 返回数据再次处理,防止钩子插件处理不够完善
$result['base']['total_price'] = ($result['base']['total_price'] <= 0) ? 0.00 : PriceNumberFormat($result['base']['total_price']);
$result['base']['actual_price'] = ($result['base']['actual_price'] <= 0) ? 0.00 : PriceNumberFormat($result['base']['actual_price']);
$result['base']['preferential_price'] = ($result['base']['preferential_price'] <= 0) ? 0.00 : PriceNumberFormat($result['base']['preferential_price']);
@ -876,7 +901,7 @@ class BuyService
}
}
return DataReturn('操作成功', 0);
return DataReturn('校验成功', 0);
}
/**
@ -942,6 +967,20 @@ class BuyService
return $ret;
}
// 支付方式
$payment_id = 0;
$is_under_line = 0;
if(!empty($params['payment_id']))
{
$payment = PaymentService::PaymentList(['where'=>['id'=>intval($params['payment_id'])]]);
if(empty($payment[0]))
{
return DataReturn('支付方式有误', -1);
}
$payment_id = $payment[0]['id'];
$is_under_line = in_array($payment[0]['payment'], config('shopxo.under_line_list')) ? 1 : 0;
}
// 清单商品
$params['is_order_submit'] = 1;
$buy = self::BuyTypeGoodsList($params);
@ -949,297 +988,218 @@ class BuyService
{
return $buy;
}
$check = self::BuyGoodsCheck(['goods'=>$buy['data']['goods'], 'is_buy'=>1]);
if($check['code'] != 0)
{
return $check;
}
// 商品销售模式
// 商品小于等于1则使用商品的类型
if(count($buy['data']['goods']) <= 1 && isset($buy['data']['goods'][0]) && isset($buy['data']['goods'][0]['goods_id']))
{
$ret = GoodsService::GoodsSalesModelType($buy['data']['goods'][0]['goods_id']);
$site_model = ($ret['data'] == 4) ? $user_site_model : $ret['data'];
}
// 销售型,自提点,销售+自提 地址处理
$address = [];
if(in_array($site_model, [0,2]))
{
if(empty($buy['data']['base']['address']))
{
return DataReturn('地址有误', -1);
} else {
$address = $buy['data']['base']['address'];
}
}
// 用户留言
$user_note = empty($params['user_note']) ? '' : str_replace(['"', "'"], '', strip_tags($params['user_note']));
// 支付方式
$payment = [];
if(!empty($params['payment_id']))
{
$pay_ret = PaymentService::PaymentList(['where'=>['id'=>intval($params['payment_id'])]]);
if(empty($pay_ret[0]))
{
return DataReturn('支付方式有误', -1);
} else {
$payment = $pay_ret[0];
}
}
// 订单默认状态
$status = (intval(MyC('common_order_is_booking', 0)) == 1) ? 0 : 1;
// 是否仅一个商品并且商品自定义类型
if(count($buy['data']['goods']) == 1)
{
$ret = GoodsService::IsGoodsSiteTypeConsistent($buy['data']['goods'][0]['goods_id']);
if($ret['code'] != 0)
{
// 是否为销售+自提
$site_model = ($ret['data'] == 4) ? $user_site_model : $ret['data'];
}
}
// 订单信息处理
$order = [
'preferential_price' => ($buy['data']['base']['preferential_price'] <= 0.00) ? 0.00 : $buy['data']['base']['preferential_price'],
'increase_price' => ($buy['data']['base']['increase_price'] <= 0.00) ? 0.00 : $buy['data']['base']['increase_price'],
'price' => ($buy['data']['base']['total_price'] <= 0.00) ? 0.00 : $buy['data']['base']['total_price'],
'total_price' => ($buy['data']['base']['actual_price'] <= 0.00) ? 0.00 : $buy['data']['base']['actual_price'],
'extension_data' => empty($buy['data']['extension_data']) ? '' : json_encode($buy['data']['extension_data']),
];
// 添加订单处理
return self::OrderInsertHandle($order, $buy['data']['goods'], $address, $params['user'], $payment, $site_model, $params);
}
public static function OrderInsertHandle($order, $goods, $address, $user, $payment, $site_model, $params = [])
{
// 订单信息处理
// 订单号没有则自动生成
if(!isset($order['order_no']))
{
$order['order_no'] = date('YmdHis').GetNumberCode(6);
}
// 订单模式
if(!isset($order['order_model']))
{
$order['order_model'] = $site_model;
}
// 订单状态
if(!isset($order['status']))
{
$order['status'] = (intval(MyC('common_order_is_booking', 0)) == 1) ? 0 : 1;
}
// 用户 id
if(!isset($order['user_id']) && !empty($user['id']))
{
$order['user_id'] = $user['id'];
}
// 订单商品数量
if(!isset($order['buy_number_count']))
{
$order['buy_number_count'] = array_sum(array_column($goods, 'stock'));
}
// 订单备注
if(!isset($order['user_note']))
{
$order['user_note'] = isset($params['user_note']) ? str_replace(['"', "'"], '', strip_tags($params['user_note'])) : '';
}
// 订单支付方式
if(!isset($order['payment_id']))
{
$order['payment_id'] = empty($payment['id']) ? 0 : $payment['id'];
}
// 是否线下支付
if(!isset($order['is_under_line']))
{
$order['is_under_line'] = (isset($payment['payment']) && in_array($payment['payment'], config('shopxo.under_line_list'))) ? 1 : 0;
}
// 客户端类型
if(!isset($order['client_type']))
{
$order['client_type'] = (APPLICATION_CLIENT_TYPE == 'pc' && IsMobile()) ? 'h5' : APPLICATION_CLIENT_TYPE;
}
// 时间
if(!isset($order['add_time']))
{
$order['add_time'] = time();
}
// 确认时间
if(isset($order['status']) && $order['status'] == 1)
{
$order['confirm_time'] = time();
}
// 订单添加前钩子
$hook_name = 'plugins_service_buy_order_insert_begin';
$ret = HookReturnHandle(Hook::listen($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'order' => &$order,
'goods' => &$goods,
'address' => &$address,
'site_model' => $site_model,
'payment' => $payment,
'payment_id' => isset($order['payment_id']) ? $order['payment_id'] : 0,
'is_under_line' => isset($order['is_under_line']) ? $order['is_under_line'] : 0,
'params' => $params,
]));
if(isset($ret['code']) && $ret['code'] != 0)
{
return $ret;
}
// 订单来源
$client_type = (APPLICATION_CLIENT_TYPE == 'pc' && IsMobile()) ? 'h5' : APPLICATION_CLIENT_TYPE;
// 开始事务
Db::startTrans();
// 订单添加
$order_id = Db::name('Order')->insertGetId($order);
if($order_id > 0)
// 循环处理
$order_ids = [];
foreach($buy['data']['goods'] as $v)
{
foreach($goods as $k=>$v)
// 商品销售模式
// 商品小于等于1则使用商品的类型
if($v['order_base']['goods_count'] == 1)
{
// 添加订单详情数据,data返回自增id
$detail_ret = self::OrderDetailInsert($order_id, $user['id'], $v);
if($detail_ret['code'] == 0)
{
$goods[$k]['id'] = $detail_ret['data'];
} else {
Db::rollback();
return $ret;
}
// 订单模式 - 虚拟信息添加
if($site_model == 3)
{
$ret = self::OrderFictitiousValueInsert($order_id, $detail_ret['data'], $user['id'], $v['goods_id']);
if($ret['code'] != 0)
{
Db::rollback();
return $ret;
}
}
$ret = GoodsService::GoodsSalesModelType($v['goods_items'][0]['goods_id']);
$site_model = ($ret['data'] == 4) ? $user_site_model : $ret['data'];
}
// 订单模式处理
// 销售型模式,自提模式,销售+自提
// 商品校验
$check = self::BuyGoodsCheck(['goods'=>$v['goods_items'], 'is_buy'=>1]);
if($check['code'] != 0)
{
return $check;
}
// 销售型,自提点,销售+自提 地址处理
$address = [];
if(in_array($site_model, [0,2]))
{
// 添加订单(收货|取货)地址
if(!empty($address))
if(empty($v['order_base']['address']))
{
$ret = self::OrderAddressInsert($order_id, $user['id'], $address);
if($ret['code'] != 0)
{
Db::rollback();
return $ret;
}
}
// 自提模式 添加订单取货码
if($site_model == 2)
{
$ret = self::OrderExtractionCcodeInsert($order_id, $user['id']);
if($ret['code'] != 0)
{
Db::rollback();
return $ret;
}
return DataReturn('地址有误', -1);
} else {
$address = $v['order_base']['address'];
}
}
} else {
Db::rollback();
return DataReturn('订单添加失败', -1);
}
// 库存扣除
if($order['status'] == 1)
{
$ret = self::OrderInventoryDeduct(['order_id'=>$order_id, 'order_data'=>$order]);
if($ret['code'] != 0)
// 订单主信息
$order = [
'order_no' => date('YmdHis').GetNumberCode(6),
'user_id' => $params['user']['id'],
'user_note' => $user_note,
'status' => $status,
'preferential_price' => ($v['order_base']['preferential_price'] <= 0.00) ? 0.00 : $v['order_base']['preferential_price'],
'increase_price' => ($v['order_base']['increase_price'] <= 0.00) ? 0.00 : $v['order_base']['increase_price'],
'price' => ($v['order_base']['total_price'] <= 0.00) ? 0.00 : $v['order_base']['total_price'],
'total_price' => ($v['order_base']['actual_price'] <= 0.00) ? 0.00 : $v['order_base']['actual_price'],
'extension_data' => empty($v['order_base']['extension_data']) ? '' : json_encode($v['order_base']['extension_data']),
'payment_id' => $payment_id,
'buy_number_count' => $v['order_base']['buy_count'],
'client_type' => $client_type,
'order_model' => $site_model,
'is_under_line' => $is_under_line,
'add_time' => time(),
];
if($order['status'] == 1)
{
$order['confirm_time'] = time();
}
// 订单添加前钩子
$hook_name = 'plugins_service_buy_order_insert_begin';
$ret = HookReturnHandle(Hook::listen($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'data' => $v,
'order' => &$order,
'goods' => &$v['goods_items'],
'params' => $params,
]));
if(isset($ret['code']) && $ret['code'] != 0)
{
return $ret;
}
// 订单添加
$order_id = Db::name('Order')->insertGetId($order);
if($order_id > 0)
{
foreach($v['goods_items'] as $k=>$v)
{
// 添加订单详情数据,data返回自增id
$detail_ret = self::OrderDetailInsert($order_id, $params['user']['id'], $v);
if($detail_ret['code'] == 0)
{
$v['goods_items'][$k]['id'] = $detail_ret['data'];
} else {
Db::rollback();
return $ret;
}
// 订单模式 - 虚拟信息添加
if($site_model == 3)
{
$ret = self::OrderFictitiousValueInsert($order_id, $detail_ret['data'], $params['user']['id'], $v['goods_id']);
if($ret['code'] != 0)
{
Db::rollback();
return $ret;
}
}
}
// 订单模式处理
// 销售型模式,自提模式,销售+自提
if(in_array($site_model, [0,2]))
{
// 添加订单(收货|取货)地址
if(!empty($address))
{
$ret = self::OrderAddressInsert($order_id, $params['user']['id'], $address);
if($ret['code'] != 0)
{
Db::rollback();
return $ret;
}
}
// 自提模式 添加订单取货码
if($site_model == 2)
{
$ret = self::OrderExtractionCcodeInsert($order_id, $params['user']['id']);
if($ret['code'] != 0)
{
Db::rollback();
return $ret;
}
}
}
} else {
Db::rollback();
return DataReturn('订单添加失败', -1);
}
// 库存扣除
if($order['status'] == 1)
{
$ret = self::OrderInventoryDeduct(['order_id'=>$order_id, 'order_data'=>$order]);
if($ret['code'] != 0)
{
// 事务回滚
Db::rollback();
return DataReturn($ret['msg'], -10);
}
}
// 订单添加成功钩子
$hook_name = 'plugins_service_buy_order_insert_end';
$ret = HookReturnHandle(Hook::listen($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'order_id' => $order_id,
'order' => $order,
'data' => $v,
'goods' => $v['goods_items'],
'address' => $address,
'params' => $params,
]));
if(isset($ret['code']) && $ret['code'] != 0)
{
// 事务回滚
Db::rollback();
return DataReturn($ret['msg'], -10);
return $ret;
}
// 订单id集合
$order_ids[] = $order_id;
}
// 订单添加成功钩子
$hook_name = 'plugins_service_buy_order_insert_end';
$ret = HookReturnHandle(Hook::listen($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'order_id' => $order_id,
'order' => $order,
'goods' => $goods,
'address' => $address,
'site_model' => $site_model,
'payment' => $payment,
'payment_id' => isset($order['payment_id']) ? $order['payment_id'] : 0,
'is_under_line' => isset($order['is_under_line']) ? $order['is_under_line'] : 0,
'params' => $params,
]));
if(isset($ret['code']) && $ret['code'] != 0)
{
// 事务回滚
Db::rollback();
return $ret;
}
// 订单提交成功
// 订单全部提交成功
Db::commit();
// 删除购物车
self::BuyCartDelete($params);
// 获取数据库订单信息
$order = Db::name('Order')->find($order_id);
// 订单添加成功钩子, 不校验返回值
$hook_name = 'plugins_service_buy_order_insert_success';
Hook::listen($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'order_id' => $order_id,
'order' => $order,
'goods' => $goods,
'address' => $address,
'site_model' => $site_model,
'payment' => $payment,
'payment_id' => isset($order['payment_id']) ? $order['payment_id'] : 0,
'is_under_line' => isset($order['is_under_line']) ? $order['is_under_line'] : 0,
'order_ids' => $order_ids,
'params' => $params,
]);
// 删除购物车
self::BuyCartDelete($params);
// 返回信息
$result = [
'order' => $order,
'order_ids' => $order_ids,
'jump_url' => MyUrl('index/order/index'),
];
// 获取订单信息
switch($order['status'])
switch($status)
{
// 预约成功
case 0 :
$msg = '预约成功';
break;
// 提交成功
// 提交成功,进入合并支付
case 1 :
$msg = '提交成功';
$result['jump_url'] = MyUrl('index/order/pay', ['id'=>$order_id]);
$result['jump_url'] = MyUrl('index/order/pay', ['ids'=>implode(',', $order_ids)]);
break;
// 默认操作成功

View File

@ -141,6 +141,12 @@ class OrderAftersaleService
return $order;
}
// 订单是否可发起售后
if($order['data']['is_can_launch_aftersale'] != 1)
{
return DataReturn('订单已过售后期,请联系客服处理', -1);
}
// 当前是否存在进行中
$where = [
['order_id', '=', intval($params['order_id'])],
@ -1559,5 +1565,28 @@ class OrderAftersaleService
return ['step0'=>$step0, 'step1'=>$step1];
}
/**
* 订单是否可发起售后
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-07-24
* @desc description
* @param [int] $collect_time [收货时间]
*/
public static function OrderIsCanLaunchAftersale($collect_time)
{
// 未收货
if(empty($collect_time))
{
return 1;
}
// 是否超出限制时间
$launch_day = intval(MyC('home_order_aftersale_return_launch_day', 30, true));
$end_time = $collect_time+($launch_day*86400);
return ($end_time >= time()) ? 1 : 0;
}
}
?>

View File

@ -20,6 +20,7 @@ use app\service\ExpressService;
use app\service\ResourcesService;
use app\service\PayLogService;
use app\service\UserService;
use app\service\OrderAftersaleService;
/**
* 订单服务层
@ -871,6 +872,9 @@ class OrderService
// 线下支付 icon 名称
$v['is_under_line_text'] = ($v['is_under_line'] == 1) ? '线下支付' : null;
// 是否可发起售后
$v['is_can_launch_aftersale'] = OrderAftersaleService::OrderIsCanLaunchAftersale($v['collect_time']);
// 创建时间
$v['add_time_time'] = date('Y-m-d H:i:s', $v['add_time']);
$v['add_time_date'] = date('Y-m-d', $v['add_time']);

View File

@ -11,6 +11,7 @@
namespace app\service;
use think\Db;
use think\facade\Hook;
use app\service\WarehouseService;
/**
@ -54,10 +55,173 @@ class OrderSplitService
}
// 商品仓库集合
$data = self::GoodsWarehouseAggregate($params['goods']);
$warehouse_goods = self::GoodsWarehouseAggregate($params['goods']);
// 分组商品基础处理
$data = self::GroupGoodsBaseHandle($warehouse_goods, $params);
// 生成订单仓库分组商品数据处理钩子
$hook_name = 'plugins_service_buy_group_goods_handle';
$ret = HookReturnHandle(Hook::listen($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'params' => $params,
'data' => &$data,
]));
if(isset($ret['code']) && $ret['code'] != 0)
{
return $ret;
}
// 根据扩展数据重新计算金额
if(!empty($data))
{
foreach($data as &$v)
{
// 是否存在扩展数据
if(!empty($v['order_base']['extension_data']))
{
// 扩展数据金额计算
$ext = self::ExtensionDataPriceHandle($v['order_base']['extension_data']);
// 增加/减少
$v['order_base']['increase_price'] = PriceNumberFormat($v['order_base']['increase_price']+$ext['inc']);
$v['order_base']['preferential_price'] = PriceNumberFormat($v['order_base']['preferential_price']+$ext['dec']);
// 实际金额/总额处理
$v['order_base']['actual_price'] = PriceNumberFormat(($v['order_base']['actual_price']+$ext['inc'])-$ext['dec']);
$v['order_base']['total_price'] = PriceNumberFormat($v['order_base']['total_price']);
}
}
}
// 返回数据
return DataReturn('操作成功', 0, $data);
}
/**
* 扩展数据解析金额
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-07-23
* @desc description
* @param [array] $data [扩展数据]
*/
public static function ExtensionDataPriceHandle($data)
{
$inc = 0;
$dec = 0;
if(!empty($data))
{
if(!is_array($data))
{
$data = json_decode($data, true);
}
foreach($data as $v)
{
if(isset($v['type']) && isset($v['price']) && $v['price'] > 0)
{
switch($v['type'])
{
// 减
case 0 :
$dec += $v['price'];
break;
// 加
case 1 :
$inc += $v['price'];
break;
}
}
}
}
return [
'inc' => $inc,
'dec' => $dec,
];
}
/**
* 分组商品基础处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-07-23
* @desc description
* @param [array] $data [分组商品]
* @param [array] $params [输入参数]
*/
public static function GroupGoodsBaseHandle($data, $params)
{
if(!empty($data))
{
foreach($data as &$v)
{
// 当前仓库的商品总价
$total_price = PriceNumberFormat(array_sum(array_column($v['goods_items'], 'total_price')));
// 订单基础信息
$v['order_base'] = [
// 总价
'total_price' => $total_price,
// 订单实际支付金额(已减去优惠金额, 已加上增加金额)
'actual_price' => $total_price,
// 优惠金额
'preferential_price' => 0.00,
// 增加金额
'increase_price' => 0.00,
// 商品总数
'goods_count' => count($v['goods_items']),
// 规格重量总计
'spec_weight_total' => array_sum(array_map(function($v) {return $v['spec_weight']*$v['stock'];}, $v['goods_items'])),
// 购买总数
'buy_count' => array_sum(array_column($v['goods_items'], 'stock')),
// 默认地址
'address' => $params['address'],
// 自提地址列表
'extraction_address' => $params['extraction_address'],
// 当前使用的站点模式
'site_model' => $params['site_model'],
// 公共站点模式
'common_site_type' => $params['common_site_type'],
// 仓库组扩展展示数据
// name 名称
// price 金额
// type 类型0减少, 1增加
// tips 提示信息
// business 业务类型(内容格式不限)
// ext 扩展数据(内容格式不限)
// $extension_data = [
// [
// 'name' => '感恩节9折',
// 'price' => 23,
// 'type' => 0,
// 'tips' => '-¥23元',
// 'business' => null,
// 'ext' => null,
// ],
// ];
'extension_data' => [],
];
}
}
return $data;
}
/**
* 商品仓库集合
* @author Devil
@ -69,24 +233,6 @@ class OrderSplitService
*/
public static function GoodsWarehouseAggregate($data)
{
// 仓库组扩展展示数据
// name 名称
// price 金额
// type 类型0减少, 1增加
// tips 提示信息
// business 业务类型(内容格式不限)
// ext 扩展数据(内容格式不限)
// $extension_data = [
// [
// 'name' => '感恩节9折',
// 'price' => 23,
// 'type' => 0,
// 'tips' => '-¥23元',
// 'business' => null,
// 'ext' => null,
// ],
// ];
// 数据分组
$result = [];
foreach($data as $v)
@ -126,7 +272,7 @@ class OrderSplitService
}
// 总价计算
$temp_v['total_price'] = $temp_v['price']*$temp_v['stock'];
$temp_v['total_price'] = PriceNumberFormat($temp_v['price']*$temp_v['stock']);
// 减除数量
$v['stock'] -= $w['inventory'];
@ -137,30 +283,12 @@ class OrderSplitService
// 仓库
$warehouse_handle = WarehouseService::DataHandle([$w]);
$result[$w['id']] = $warehouse_handle[0];
$result[$w['id']]['extension_data'] = [
[
'name' => '感恩节9折',
'price' => 23,
'type' => 0,
'tips' => '-¥23元',
'business' => null,
'ext' => null,
],
];
$result[$w['id']]['goods_items'] = [];
unset($result[$w['id']]['is_default'], $result[$w['id']]['level'], $result[$w['id']]['inventory']);
// 订单基础信息
$result[$w['id']]['items_total_price'] = 0;
$result[$w['id']]['items_stock_total'] = 0;
}
// 商品归属到仓库下
$result[$w['id']]['goods_items'] = array_merge($result[$w['id']]['goods_items'], [$temp_v]);
// 基础信息
$result[$w['id']]['items_total_price'] += $temp_v['total_price'];
$result[$w['id']]['items_stock_total'] += $temp_v['stock'];
} else {
break;
}
@ -178,20 +306,11 @@ class OrderSplitService
// 仓库
$warehouse_handle = WarehouseService::DataHandle([$warehouse_default]);
$result[$warehouse_default['id']] = $warehouse_handle[0];
$result[$warehouse_default['id']]['extension_data'] = [];
$result[$warehouse_default['id']]['goods_items'] = [];
// 订单基础信息
$result[$warehouse_default['id']]['items_total_price'] = 0;
$result[$warehouse_default['id']]['items_stock_total'] = 0;
}
// 商品归属到仓库下
$result[$warehouse_default['id']]['goods_items'][] = $v;
// 基础信息
$result[$warehouse_default['id']]['items_total_price'] += $temp_v['total_price'];
$result[$warehouse_default['id']]['items_stock_total'] += $temp_v['stock'];
}
}
}

View File

@ -36,7 +36,7 @@ return array (
array (
0 => 'app\\plugins\\freightfee\\Hook',
),
'plugins_service_buy_handle' =>
'plugins_service_buy_group_goods_handle' =>
array (
0 => 'app\\plugins\\freightfee\\Hook',
),

View File

@ -48,7 +48,6 @@ ul.logistics-list li img, ul.payment-list li img { width: 36px; height: 36px; ve
}
/*合计*/
.buy-point-discharge{font-size:14px ;font-weight: 700;}
.box{float:left;width:70%;height:40px ;line-height:40px ;font-size: 14px;text-align: right;padding-right:10px ;}
.pay-address{display: none;}
.nav-buy .btn-go{float:left;width:30%;color:#fff ;background:#d2364c ;text-align: center;height:40px ;line-height:40px ;font-size: 14px; border: 0; }
@ -111,7 +110,6 @@ ul.address-list, .business-item ul { overflow: hidden; }
.base-real-pay {line-height: 16px;margin: 0px 0px 10px;position: relative;}
.base-real-pay .g_price span {font-size: 26px;}
.price .nav-total-price {font: 700 26px tahoma;}
.order-nav .buy-footer-address .buy-line-title {color: #404040;font-weight: 700;}
/*地址管理*/
.address ul{margin-top: 10px; padding: 1px;}
ul.address-list li{display:block; width: calc(33% - 5px);height: 130px;float: left;margin:0 10px 10px 0 ;padding:10px;border: 1px solid #e5e5e5;}
@ -167,7 +165,6 @@ ul.address-list, .business-item ul { overflow: hidden; }
.goods-base { float: left; top: 0; margin-left: 85px; }
.goods-attr { margin-top: 5px; }
.goods-attr li { color: #888; line-height: 16px; }
.original-price, .line-price { font-family: Verdana,Tahoma,arial; }
.original-price { color: #999; text-decoration: line-through; }
.am-table { margin-bottom: 10px; }
.am-table > tbody > tr > td { border-top: 1px solid #eee; }

View File

@ -241,13 +241,8 @@ color: #F5F5F2;font-size: 12px;cursor:pointer;border-radius:0px 0px; position: a
font-weight: bold;
}
/**
* 灰色文字标记
*/
.gray-text { color: #999; }
/* 价格颜色 */
.price strong {color: #c00; font-weight: 600; }
.price, .price strong {color: #c00; }
/* 公共错误提示页面 */
.tips-error, .tips-success { margin: 10% 0; background: #fff; }

View File

@ -180,7 +180,7 @@ fieldset legend{margin-left:15px;padding-left:3px;padding-right:3px;color:#333;}
/*价格*/
.tb-detail-price{text-align: left; position: relative;}
.tb-detail-price .price em {font-family: arial;}
.tb-detail-price .original-price-value {text-decoration:line-through; font-size:14px; }
.tb-detail-price .original-price-value {text-decoration:line-through; font-size:14px; color: #999; }
.iteminfo_mktprice {padding-top: 10px;}
.iteminfo_mktprice em, .goods-price { color:#c00;}
.tb-detail-price dd {display: inline-block;}
@ -205,7 +205,7 @@ fieldset legend{margin-left:15px;padding-left:3px;padding-right:3px;color:#333;}
.goods-video-submit-close { font-size: 60px; color: #999; cursor: pointer; }
.goods-video-submit-start:hover,
.goods-video-submit-close:hover { color: #666; }
.goods-video-submit-close { z-index: 4; width: 50px; height: 50px; line-height: 48px; text-align: center; padding: 0; border: 2px solid #999; border-radius: 1000px; }
.goods-video-submit-close { z-index: 4; width: 50px; height: 50px; line-height: 35px; text-align: center; padding: 0; border: 2px solid #999; border-radius: 1000px; }
/* 视频 放大镜 */
.box .goods-video-submit-start { left: 1px; bottom: 85px; z-index: 2; padding: 10px 10px 2px 10px; }

View File

@ -206,7 +206,7 @@ $(function()
} else {
Prompt(result.msg);
}
$('.select .title-tips strong').text(result.data.total);
$('.select .title-tips strong').text(result.data.total || 0);
},
error:function(xhr, type)
{

View File

@ -26,7 +26,7 @@
{{spec.type}}:{{spec.value}}
</view>
</block>
<view class="orderaftersale-btn-text" catchTap="orderaftersale_event" data-oid="{{item.id}}" data-did="{{detail.id}}">{{detail.orderaftersale_btn_text}}</view>
<view a:if="{{(item.is_can_launch_aftersale == 1 || (detail.orderaftersale || null) != null) && ($detail.orderaftersale_btn_text || null) != null}}" class="orderaftersale-btn-text" catchTap="orderaftersale_event" data-oid="{{item.id}}" data-did="{{detail.id}}">{{detail.orderaftersale_btn_text}}</view>
</view>
<view class="oh goods-price">
<text class="sales-price">{{price_symbol}}{{detail.price}}</text>

View File

@ -26,7 +26,7 @@
{{spec.type}}:{{spec.value}}
</view>
</block>
<view class="orderaftersale-btn-text" catchtap="orderaftersale_event" data-oid="{{item.id}}" data-did="{{detail.id}}">{{detail.orderaftersale_btn_text}}</view>
<view s-if="(item.is_can_launch_aftersale == 1 || (detail.orderaftersale || null) != null) && ($detail.orderaftersale_btn_text || null) != null" class="orderaftersale-btn-text" catchtap="orderaftersale_event" data-oid="{{item.id}}" data-did="{{detail.id}}">{{detail.orderaftersale_btn_text}}</view>
</view>
<view class="oh goods-price">
<text class="sales-price">{{price_symbol}}{{detail.price}}</text>

View File

@ -26,7 +26,7 @@
{{spec.type}}:{{spec.value}}
</view>
</block>
<view class="orderaftersale-btn-text" catchtap="orderaftersale_event" data-oid="{{item.id}}" data-did="{{detail.id}}">{{detail.orderaftersale_btn_text}}</view>
<view qq:if="{{(item.is_can_launch_aftersale == 1 || (detail.orderaftersale || null) != null) && ($detail.orderaftersale_btn_text || null) != null}}" class="orderaftersale-btn-text" catchtap="orderaftersale_event" data-oid="{{item.id}}" data-did="{{detail.id}}">{{detail.orderaftersale_btn_text}}</view>
</view>
<view class="oh goods-price">
<text class="sales-price">{{price_symbol}}{{detail.price}}</text>

View File

@ -26,7 +26,7 @@
{{spec.type}}:{{spec.value}}
</view>
</block>
<view class="orderaftersale-btn-text" catchtap="orderaftersale_event" data-oid="{{item.id}}" data-did="{{detail.id}}">{{detail.orderaftersale_btn_text}}</view>
<view tt:if="{{(item.is_can_launch_aftersale == 1 || (detail.orderaftersale || null) != null) && ($detail.orderaftersale_btn_text || null) != null}}" class="orderaftersale-btn-text" catchtap="orderaftersale_event" data-oid="{{item.id}}" data-did="{{detail.id}}">{{detail.orderaftersale_btn_text}}</view>
</view>
<view class="oh goods-price">
<text class="sales-price">{{price_symbol}}{{detail.price}}</text>

View File

@ -26,7 +26,7 @@
{{spec.type}}:{{spec.value}}
</view>
</block>
<view class="orderaftersale-btn-text" catchtap="orderaftersale_event" data-oid="{{item.id}}" data-did="{{detail.id}}">{{detail.orderaftersale_btn_text}}</view>
<view wx:if="{{(item.is_can_launch_aftersale == 1 || (detail.orderaftersale || null) != null) && ($detail.orderaftersale_btn_text || null) != null}}" class="orderaftersale-btn-text" catchtap="orderaftersale_event" data-oid="{{item.id}}" data-did="{{detail.id}}">{{detail.orderaftersale_btn_text}}</view>
</view>
<view class="oh goods-price">
<text class="sales-price">{{price_symbol}}{{detail.price}}</text>