|
|
@@ -38,7 +38,10 @@ class ShopOrderLogic extends BaseLogic
|
|
|
if(empty($shop_carts)){
|
|
|
throw new Exception('购物车商品不存在');
|
|
|
}
|
|
|
-
|
|
|
+ $addressInfo = ShopAddress::field('area,address,house_number,contact_number,contact_people')->findOrEmpty($params['address_id']);
|
|
|
+ if($addressInfo->isEmpty()){
|
|
|
+ throw new \Exception('收货地址不存在');
|
|
|
+ }
|
|
|
//生成订单编号
|
|
|
$sn = generate_sn(ShopOrders::class, 'sn');
|
|
|
$shop_order_goods = array();
|
|
|
@@ -85,14 +88,15 @@ class ShopOrderLogic extends BaseLogic
|
|
|
'shop_order_type' => 1,
|
|
|
'worker_id' => $params['user_id'],
|
|
|
'sn' => $sn,
|
|
|
- 'real_name' => $params['real_name'],
|
|
|
- 'mobile' => $params['mobile'],
|
|
|
- 'address' => $params['address'],
|
|
|
+ 'real_name' => $addressInfo->contact_people,
|
|
|
+ 'mobile' => $addressInfo->contact_number,
|
|
|
+ 'address' => trim($addressInfo->area .$addressInfo->address . $addressInfo->house_number),
|
|
|
'pay_status' => 0,
|
|
|
'paw_way' => 2,
|
|
|
'order_terminal' => $params['terminal'],
|
|
|
'amount_total' => $amount_total,
|
|
|
'order_amount' => $amount,
|
|
|
+ 'address_json' => $addressInfo->toArray()
|
|
|
]);
|
|
|
|
|
|
//生成订单商品镜像
|
|
|
@@ -100,7 +104,6 @@ class ShopOrderLogic extends BaseLogic
|
|
|
$ShopOrderGoods->saveAll($shop_order_goods);
|
|
|
//清除购物车商品
|
|
|
ShopCart::whereIn('id',$params['shop_cart_id'])->delete();
|
|
|
-
|
|
|
Db::commit();
|
|
|
} catch (\Exception $e) {
|
|
|
self::setError($e->getMessage());
|
|
|
@@ -122,8 +125,8 @@ class ShopOrderLogic extends BaseLogic
|
|
|
public static function detail($params): array
|
|
|
{
|
|
|
$detail = ShopOrders::with(['orderGoods'=>function(Query $query){
|
|
|
- $query->field(['sn','goods_name','goods_image','number','service_fee','company_name','delivery_type','shop_goods_type','goods_specs_inventory_id','specs_type','custom_attribute_items','specs'])->append(['spec_arr','delivery_type_text','shop_goods_type_text']);
|
|
|
- }])->field('id, sn, real_name,mobile, address,pay_time, paw_way,pay_sn, pay_status, refund_status, refund_transaction_id,create_time,shop_order_type,amount_total, order_amount')
|
|
|
+ $query->field(['sn','goods_name','goods_image','number','service_fee','service_total','company_name','delivery_type','shop_goods_type','goods_specs_inventory_id','specs_type','custom_attribute_items','specs'])->append(['spec_arr','delivery_type_text','shop_goods_type_text']);
|
|
|
+ }])->field('id, sn, real_name,mobile, address,address_json,pay_time, paw_way,pay_sn, pay_status, refund_status, refund_transaction_id,create_time,shop_order_type,amount_total, order_amount')
|
|
|
->append(['pay_way_text','pay_status_text','refund_status_text'])->where(['sn'=> $params['sn'],'worker_id'=>$params['worker_id']])->findOrEmpty()->toArray();
|
|
|
$orderGoodsArr = [];
|
|
|
$companyNameArr = array_unique(array_column($detail['orderGoods'],'company_name'));
|