OrderGoods.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace app\model\order;
  11. use app\model\BaseModel;
  12. /**
  13. * 商品
  14. */
  15. class OrderGoods extends BaseModel
  16. {
  17. /**
  18. * 获取商品sku分页列表
  19. * @param array $condition
  20. * @param number $page
  21. * @param string $page_size
  22. * @param string $order
  23. * @param string $field
  24. */
  25. public function getOrderGoodsPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = '*', $alias = '', $join = '')
  26. {
  27. $res = model('order_goods')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
  28. foreach ($res[ 'list' ] as $k => $v) {
  29. if (isset($v[ 'num' ])) {
  30. $res[ 'list' ][ $k ][ 'num' ] = numberFormat($res[ 'list' ][ $k ][ 'num' ]);
  31. }
  32. }
  33. return $this->success($res);
  34. }
  35. /**
  36. * 订单项商品真实支付金额
  37. * @param $params
  38. * @return array
  39. */
  40. public function getOrderRealPayGoodsMoney($params)
  41. {
  42. $order_goods_id = $params[ 'order_goods_id' ];
  43. $order_id = $params[ 'order_id' ];
  44. $condition = array (
  45. [ 'order_id', '=', $order_id ]
  46. );
  47. $order_info = model('order')->getInfo($condition, 'order_money, pay_money, delivery_money, coupon_money, balance_money, invoice_money, point_money');
  48. $order_money = $order_info[ 'order_money' ];
  49. $pay_money = $order_info[ 'pay_money' ];
  50. $delivery_money = $order_info[ 'delivery_money' ];
  51. $invoice_money = $order_info[ 'invoice_money' ];
  52. $balance_money = $order_info[ 'balance_money' ];
  53. $coupon_money = $order_info[ 'coupon_money' ];
  54. $point_money = $order_info[ 'point_money' ];
  55. $real_pay_goods_money = $pay_money - $delivery_money - $invoice_money;//总的商品真实支付金额
  56. $real_goods_money = $order_money - $delivery_money - $invoice_money;
  57. $item_real_goods_money = $params[ 'real_goods_money' ];//订单项真实支付金额
  58. $item_real_pay_goods_money = $real_goods_money > 0 ? round($item_real_goods_money / $real_goods_money * $real_pay_goods_money, 2) : 0;//四舍五入可能会多
  59. return $this->success($item_real_pay_goods_money);
  60. }
  61. }