|
@@ -47,6 +47,7 @@ class OrderLogic extends BaseLogic
|
|
|
'updaterid' => self::$aid,
|
|
|
'updater' => self::$aname,
|
|
|
'updatetime' => $date,
|
|
|
+ 'remark' => $data['remark']
|
|
|
];
|
|
|
|
|
|
//子订单数据
|
|
@@ -55,7 +56,6 @@ class OrderLogic extends BaseLogic
|
|
|
//库存变动记录数据
|
|
|
$insert_inventory_exchange_log = [];
|
|
|
|
|
|
-
|
|
|
//兑换商品
|
|
|
if ($data['type'] == MasterOrderModel::$type_exchange_good) {
|
|
|
|
|
@@ -82,6 +82,7 @@ class OrderLogic extends BaseLogic
|
|
|
'card_id' => self::$card_id,
|
|
|
'uid' => self::$aid,
|
|
|
'child_id' => $item['id'],
|
|
|
+ 'child_title' => $item['good_name'],
|
|
|
'num' => $num[$item['id']],
|
|
|
'price' => 0,
|
|
|
'total_price' => 0,
|
|
@@ -171,6 +172,7 @@ class OrderLogic extends BaseLogic
|
|
|
'card_id' => self::$card_id,
|
|
|
'uid' => self::$aid,
|
|
|
'child_id' => $item['id'],
|
|
|
+ 'child_title' => $item['title'],
|
|
|
'num' => $num[$item['id']] ?? 0,
|
|
|
'price' => $price,
|
|
|
'total_price' => $total_price,
|
|
@@ -212,13 +214,14 @@ class OrderLogic extends BaseLogic
|
|
|
$total_price = bcmul($rs['price'], $num[$item['id']] ?? 0, 2);//总价
|
|
|
$amount = bcadd($amount, $total_price, 2);//总金额
|
|
|
|
|
|
- $order_insert[] = [
|
|
|
+ $insert_order[] = [
|
|
|
'masterOrderCode' => $masterOrderCode,
|
|
|
'orderCode' => $orderCode,
|
|
|
'company_id' => self::$company_id,
|
|
|
'card_id' => self::$card_id,
|
|
|
'uid' => self::$aid,
|
|
|
'child_id' => $item['id'],
|
|
|
+ 'child_title' => $item['good_name'],
|
|
|
'num' => $num[$item['id']],
|
|
|
'price' => $rs['price'],
|
|
|
'total_price' => $total_price,
|
|
@@ -299,22 +302,27 @@ class OrderLogic extends BaseLogic
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//订单列表
|
|
|
public static function list(array $data = []): Json
|
|
|
{
|
|
|
- $db = OrderModel::alias('a')
|
|
|
- ->leftJoin('good b', 'b.id=a.good_id AND b.is_del=' . CommonModel::$del_normal)
|
|
|
- ->where(['a.is_del'=>CommonModel::$del_normal, 'a.uid' => self::$aid]);
|
|
|
+ $db = MasterOrderModel::where(['uid' => self::$aid]);
|
|
|
|
|
|
- if ($data['status'] != '') $db->where('a.status', $data['status']);
|
|
|
+ if ($data['status'] != '') $db->where('status', $data['status']);
|
|
|
|
|
|
- $count = $db->count('a.id');
|
|
|
+ $count = $db->count('id');
|
|
|
|
|
|
$list = $db
|
|
|
- ->field('a.id,a.orderCode,b.good_name,a.num,a.status,a.addtime,a.type,a.price,a.total_price')
|
|
|
+ ->field('id,masterOrderCode,amount,status,addtime')
|
|
|
+ ->append(['order_list'])
|
|
|
+ ->withAttr('order_list', function ($val, $da) {
|
|
|
+ return OrderModel::field('id,orderCode,child_title,price,num,total_price')
|
|
|
+ ->where(['is_del' => CommonModel::$del_normal, 'masterOrderCode' => $da['masterOrderCode'], 'uid' => self::$aid])
|
|
|
+ ->order('id')
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
+ })
|
|
|
->page($data['page'], $data['size'])
|
|
|
- ->order('a.id', 'desc')
|
|
|
+ ->order('id', 'desc')
|
|
|
->select()
|
|
|
->toArray();
|
|
|
|
|
@@ -325,15 +333,21 @@ class OrderLogic extends BaseLogic
|
|
|
//订单详情
|
|
|
public static function info(int $id = 0): Json
|
|
|
{
|
|
|
- $rs = OrderModel::alias('a')
|
|
|
- ->field('a.id,a.orderCode,a.status,a.addtime,a.type,b.good_name,a.num,c.contactor,c.mobile,c.addr,c.addr_code,a.price,a.total_price,a.post_name,a.post_code,a.remark,"支付流水号" p')
|
|
|
- ->leftJoin('good b', 'b.id=a.good_id AND b.is_del=' . CommonModel::$del_normal)
|
|
|
+ $rs = MasterOrderModel::alias('a')
|
|
|
+ ->field('a.id,a.masterOrderCode,a.amount,a.status,a.addtime,c.contactor,c.mobile,c.addr,c.addr_code,a.transaction_id,a.remark')
|
|
|
->leftJoin('addr c', 'c.id=a.addr_id AND c.is_del=' . CommonModel::$del_normal)
|
|
|
- ->leftJoin('pay_info d', 'd.id=a.pay_info_id')
|
|
|
- ->where(['a.is_del' => CommonModel::$del_normal, 'a.id' => $id, 'a.uid' => self::$aid])
|
|
|
+ ->append(['order_list'])
|
|
|
+ ->withAttr('order_list', function ($val, $da) {
|
|
|
+ return OrderModel::field('id,orderCode,child_title,child_cover,price,num,total_price')
|
|
|
+ ->where(['is_del' => CommonModel::$del_normal, 'masterOrderCode' => $da['masterOrderCode'], 'uid' => self::$aid])
|
|
|
+ ->order('id')
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
+ })
|
|
|
->withAttr('addr', function ($val, $da) {
|
|
|
return $da['addr_code'] ? get_addr_name($da['addr_code']) . $val : $val;
|
|
|
})
|
|
|
+ ->where('a.id', $id)
|
|
|
->findOrEmpty()
|
|
|
->toArray();
|
|
|
|