|
@@ -240,26 +240,72 @@ Class Manage
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
if ($goods_info['price_type'] > 2 && isset($goods_info['goods']) && is_array($goods_info['goods'])) {
|
|
|
$heji = 0;
|
|
|
- $heji = $this->total($goods);
|
|
|
-
|
|
|
+ $heji = $this->total($goods,$v1['num']);
|
|
|
+
|
|
|
foreach ($goods_info['goods'] as $key => $val) {
|
|
|
-
|
|
|
- $youhui = ($val['price']*($val['num']+$v1['num'])-($val['price']*($val['num']+$v1['num'])/$heji)*$v['price'])*$v1['num'];
|
|
|
- $card_price = ($v['card_code_cash']/$heji*($val['price']*($val['num']+$v1['num'])))*$v1['num'];
|
|
|
- $wallet_price = ($v['wallet_cash']/$heji*($val['price']*($val['num']+$v1['num'])))*$v1['num'];
|
|
|
- $goodsfu = $val['price']*($val['num']+$v1['num'])-$youhui-$card_price-$wallet_price;
|
|
|
- if ($key == 0) {
|
|
|
- $price = round($v1['price']*$v1['num']-$v1['discount_cash'],2);
|
|
|
+
|
|
|
+ $dnum = round($val['num']*$v1['num'],2);
|
|
|
+ $bili = round($val['price']*$dnum /$heji,2);
|
|
|
+
|
|
|
+ $price_money = $val['price']*$dnum*$v['discount_cash'];
|
|
|
+
|
|
|
+ if ($v['card_code_cash'] && $v['card_code_cash']>0){
|
|
|
+ $card_price = round(($v['card_code_cash']/$v['oprice']*($val['price']*$dnum)),2);
|
|
|
+ } else {
|
|
|
+ $card_price = 0;
|
|
|
+ }
|
|
|
+ $wallet_price = round(($v['wallet_cash']/$v['oprice']*($val['price']*$dnum)),2);
|
|
|
+ $goodsfu = 0;
|
|
|
+ if ($v1['discount_id']<=0) {
|
|
|
+ $youhui = 0;
|
|
|
+ if ($card_price + $wallet_price >=$val['price']*$dnum){
|
|
|
+ $goodsfu = 0;
|
|
|
+ } elseif ($card_price + $wallet_price ==0) {
|
|
|
+ $goodsfu = round($val['price']*$dnum,2);
|
|
|
+ } else {
|
|
|
+ $goodsfu = round($val['price']*$dnum-($card_price + $wallet_price),2);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ } else {
|
|
|
+ $act = Dever::db('act/discount')->find($v['discount_id']);
|
|
|
+ if ($act && $act['num']) {
|
|
|
+ $act_num = $act['num']/10;
|
|
|
+ }
|
|
|
+ if ($card_price + $wallet_price == 0) {
|
|
|
+ $goodsfu = round($val['price']*$dnum*$act_num,2);
|
|
|
+ $youhui = round($val['price']*$dnum-$goodsfu);
|
|
|
+ } elseif ($card_price + $wallet_price >=$val['price']*$dnum) {
|
|
|
+ $goodsfu = 0;
|
|
|
+ $youhui = round($val['price']*$dnum-$goodsfu-($card_price + $wallet_price),2);
|
|
|
+ } else {
|
|
|
+ $goodsfu = round($val['price']*$dnum-($card_price + $wallet_price),2);
|
|
|
+ $youhui = round($val['price']*$dnum-$goodsfu,2);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if ($key == 0 && $k1 ==0) {
|
|
|
+ $price = $v['price'];
|
|
|
$shifu = round($v['price'],2);
|
|
|
$order_num = $v1['num'];
|
|
|
- $oprice = round($v1['price']*$v1['num'],2);
|
|
|
+ $oprice = $v['oprice'];
|
|
|
$coupon_cash = round($v1['coupon_cash'],2);
|
|
|
$discount_cash = round($v1['discount_cash'],2);
|
|
|
$card_code_cash = round($v['card_code_cash'],2);
|
|
|
$wallet_cash = round($v['wallet_cash'],2);
|
|
|
+ if ($v['status'] == 8) {
|
|
|
+ $refund_cash = $refund_cash;
|
|
|
+ $ka = $ka;
|
|
|
+ $money = 0;
|
|
|
+ }
|
|
|
+
|
|
|
} else {
|
|
|
$price = 0;
|
|
|
$shifu = 0;
|
|
@@ -269,12 +315,13 @@ Class Manage
|
|
|
$discount_cash = 0;
|
|
|
$card_code_cash = 0;
|
|
|
$wallet_cash = 0;
|
|
|
+ if ($v['status'] == 8) {
|
|
|
+ $refund_cash = 0;
|
|
|
+ $ka = 0;
|
|
|
+ $money = 0;
|
|
|
+ }
|
|
|
}
|
|
|
- if($v1['num']>1) {
|
|
|
- $dnum = round($val['num']+$v1['num'],2);
|
|
|
- } else {
|
|
|
- $dnum = round($val['num'],2);
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
$d = array
|
|
|
(
|
|
@@ -290,12 +337,12 @@ Class Manage
|
|
|
|
|
|
round($val['price'],2),
|
|
|
$dnum,
|
|
|
- round(($val['price']*($val['num']+$v1['num'])),2),
|
|
|
+ round(($val['price']*$dnum),2),
|
|
|
round($youhui,2),
|
|
|
$goodsfu,
|
|
|
$card_price,
|
|
|
$wallet_price,
|
|
|
- $price,
|
|
|
+ $price,
|
|
|
|
|
|
$v['card'],
|
|
|
$v['card_code_card']."\t",
|
|
@@ -328,7 +375,17 @@ Class Manage
|
|
|
$body[] = $d;
|
|
|
}
|
|
|
} else {
|
|
|
- if ($k1 == 0) {
|
|
|
+ if ($ka > 0 || $money > 0) {
|
|
|
+ $st = Dever::db('shop/sell_order_goods')->find(Array('order_id'=>$v['id'],'status'=>3));
|
|
|
+ if ($v1['goods_id'] == $st['goods_id']) {
|
|
|
+ $ka = round($ka,2);
|
|
|
+ $money = round($money,2);
|
|
|
+ } else {
|
|
|
+ $ka = 0;
|
|
|
+ $money = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($k1 == 0 ) {
|
|
|
$discount_cash = round($v['discount_cash'],2);
|
|
|
$card_code_cash = round($v['card_code_cash'],2);
|
|
|
$wallet_cash = round($v['wallet_cash'],2);
|
|
@@ -337,6 +394,8 @@ Class Manage
|
|
|
$order_num = $v['num'];
|
|
|
$oprice = round($v['oprice'],2);
|
|
|
$coupon_cash = round($v['coupon_cash'],2);
|
|
|
+
|
|
|
+
|
|
|
} else {
|
|
|
$discount_cash = 0;
|
|
|
$card_code_cash = 0;
|
|
@@ -346,17 +405,19 @@ Class Manage
|
|
|
$order_num = 0;
|
|
|
$oprice = 0;
|
|
|
$coupon_cash = 0;
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
$dyouhui = round($v1['discount_cash'],2);
|
|
|
-
|
|
|
-
|
|
|
$dcard_price = $v['card_code_cash']/$v['oprice']*($v1['price']*$v1['num']);
|
|
|
$dwallet_price = $v['wallet_cash']/$v['oprice']*($v1['price']*$v1['num']);
|
|
|
$dgoodsfu = $v1['price']*$v1['num']-$dyouhui-$dcard_price-$dwallet_price;
|
|
|
+
|
|
|
+
|
|
|
if ($dgoodsfu<0){
|
|
|
$dgoodsfu = 0;
|
|
|
}
|
|
|
+
|
|
|
$d = array
|
|
|
(
|
|
|
$shop_type,
|
|
@@ -372,11 +433,12 @@ Class Manage
|
|
|
round($v1['price'],2),
|
|
|
round($v1['num'],2),
|
|
|
round(($v1['price']*$v1['num']),2),
|
|
|
+
|
|
|
round($dyouhui,2),
|
|
|
$dgoodsfu,
|
|
|
$dcard_price,
|
|
|
$dwallet_price,
|
|
|
- $zhifu,
|
|
|
+ $zhifu,
|
|
|
|
|
|
$v['card'],
|
|
|
$v['card_code_card']."\t",
|
|
@@ -399,8 +461,8 @@ Class Manage
|
|
|
$refund_cdate,
|
|
|
|
|
|
round($refund_cash, 2),
|
|
|
- round($ka,2),
|
|
|
- round($money,2),
|
|
|
+ $ka,
|
|
|
+ $money,
|
|
|
|
|
|
$address_contact,
|
|
|
$address_mobile,
|
|
@@ -421,16 +483,212 @@ Class Manage
|
|
|
$file = '商品销售相关数据';
|
|
|
return Dever::excelExport($body, $header, $file);
|
|
|
}
|
|
|
- public function total($goods){
|
|
|
-
|
|
|
+
|
|
|
+ public function total($goods,$num){
|
|
|
if ($goods) {
|
|
|
$price = 0;
|
|
|
foreach ($goods as $k => $v) {
|
|
|
- $price += $v['price'] * $v['num'];
|
|
|
+ $price += $v['price'] * $v['num']*$num;
|
|
|
}
|
|
|
return $price;
|
|
|
}
|
|
|
}
|
|
|
+ public function duihuan_api()
|
|
|
+ {
|
|
|
+ $start = Dever::input('start');
|
|
|
+ $end = Dever::input('end');
|
|
|
+ $fastart = Dever::input('fastart');
|
|
|
+ $faend = Dever::input('faend');
|
|
|
+ $fstart = Dever::input('fstart');
|
|
|
+ $fend = Dever::input('fend');
|
|
|
+ $name = Dever::input('goods_name');
|
|
|
+ $shop_name = Dever::input('shop_name');
|
|
|
+ $order_num = Dever::input('order_num');
|
|
|
+ $parent_type = Dever::input('cate');
|
|
|
+ if ($start) {
|
|
|
+ $where['start'] = strtotime($start);
|
|
|
+ }
|
|
|
+ if ($end) {
|
|
|
+ $where['end'] = strtotime($end);
|
|
|
+ }
|
|
|
+ if ($fastart) {
|
|
|
+ $where['fastart'] = strtotime($fastart);
|
|
|
+ }
|
|
|
+ if ($faend) {
|
|
|
+ $where['faend'] = strtotime($faend);
|
|
|
+ }
|
|
|
+ if ($fstart) {
|
|
|
+ $where['fstart'] = strtotime($fstart);
|
|
|
+ }
|
|
|
+ if ($fend) {
|
|
|
+ $where['fend'] = strtotime($fend);
|
|
|
+ }
|
|
|
+ if ($parent_type && $parent_type>0) {
|
|
|
+ $where['parent_type'] = $parent_type;
|
|
|
+ } else {
|
|
|
+ $where['parent_type'] = '1,3';
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($name) {
|
|
|
+ $where['name'] = $name;
|
|
|
+ }
|
|
|
+ if ($shop_name) {
|
|
|
+ $where['type'] = 1;
|
|
|
+ $shop = Dever::db('shop/info')->find(array('name'=>$name));
|
|
|
+ if ($shop) {
|
|
|
+ $where['type_id'] = $shop['id'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($order_num) {
|
|
|
+ $where['order_num'] = $order_num;
|
|
|
+ }
|
|
|
+ $where['state'] = 1;
|
|
|
+ $data = Dever::db('shop/buy_order')->getDui($where);
|
|
|
+ $header = array('门店类型', '门店编号', '门店名称', '订单号', '商品编码', '存货编码', '商品名称', '规格型号', '税率', '商品单价', '购买数量', '商品合计金额', '代理商注册时间', '下单时间', '付款时间', '发货时间', '完成时间', '订单总数量', '订单总金额', '订单实付金额', '资金账户抵扣金额', '订单状态', '退款状态', '退款时间', '退款金额', '收件人', '收件人手机', '收件人地址');
|
|
|
+ $body = array();
|
|
|
+ if ($data) {
|
|
|
+ foreach($data as $k => $v){
|
|
|
+ $shop = Dever::db('shop/info')->find($v['type_id']);
|
|
|
+ if ($shop['type'] ==1) {
|
|
|
+ $shop_type = '体验店';
|
|
|
+ } elseif ($shop['type'] ==10) {
|
|
|
+ $shop_type = '平台商城';
|
|
|
+ }
|
|
|
+ $zhuce = '';
|
|
|
+ $address_contact = '';
|
|
|
+ $address_mobile = '';
|
|
|
+ $address_info = '';
|
|
|
+ $shifu = 0;
|
|
|
+ if ($v['parent_type'] == 3) {
|
|
|
+ $parent_order = Dever::db('agent/dh_order')->find($v['parent_order_id']);
|
|
|
+ $shifu = 0;
|
|
|
+ $record_cash = 0;
|
|
|
+ } else {
|
|
|
+ $shifu = round($v['price'],2);
|
|
|
+ $record_cash = round($v['record_cash'],2);
|
|
|
+ }
|
|
|
+ if ($v['type'] == 1) {
|
|
|
+ $type_info = Dever::db('shop/info')->find($v['type_id']);
|
|
|
+ } elseif ($info['type'] == 2) {
|
|
|
+ $type_info = Dever::db('store/info')->find($v['type_id']);
|
|
|
+ } elseif ($info['type'] == 3) {
|
|
|
+ $type_info = Dever::db('store/info')->find($v['type_id']);
|
|
|
+ }
|
|
|
+ if (isset($parent_order) && $parent_order && isset($parent_order['uid']) && $parent_order['uid']) {
|
|
|
+ if ($parent_order['address_id']) {
|
|
|
+ $address = Dever::load('passport/address')->getOne($parent_order['uid'], $parent_order['address_id']);
|
|
|
+ if($address) {
|
|
|
+ $address_contact = $address['contact'];
|
|
|
+ $address_mobile = $address['mobile'];
|
|
|
+ $address_info = $address['address_info'];
|
|
|
+ $member = Dever::db('agent/member')->find(array('mobile'=>$address['mobile']));
|
|
|
+ if ($member) {
|
|
|
+ $zhuce = date('Y-m-d H:i',$member['cdate']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } elseif (isset($type_info) && $type_info) {
|
|
|
+ $address_contact = $type_info['truename'];
|
|
|
+ $address_mobile = $type_info['mobile'];
|
|
|
+ $address_info = $type_info['address'];
|
|
|
+ }
|
|
|
+ $goods = Dever::db('shop/buy_order_goods')->select(array('order_id' => $v['id']));
|
|
|
+ $goods_status = Dever::db('shop/buy_order_goods')->config['status'];
|
|
|
+ foreach ($goods as $k1 => $v1) {
|
|
|
+ $goods_info = Dever::load('goods/lib/info')->getInfoBySku($v1['goods_id'], $v1['sku_id']);
|
|
|
+ if (isset($goods_info['sku'])) {
|
|
|
+ $sku = $goods_info['sku']['string'];
|
|
|
+ } else {
|
|
|
+ $sku = '';
|
|
|
+ }
|
|
|
+ if ($v['cdate']) {
|
|
|
+ $cdate = date('Y-m-d H:i',$v['cdate']);
|
|
|
+
|
|
|
+ }
|
|
|
+ $fadate = '';
|
|
|
+ if ($v['fadate']) {
|
|
|
+ $fadate = date('Y-m-d H:i',$v['fadate']);
|
|
|
+ }
|
|
|
+ $fdate = '';
|
|
|
+ if ($v['fdate']) {
|
|
|
+ $fdate = date('Y-m-d H:i',$v['fdate']);
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($v1['status'] == 1) {
|
|
|
+ $refund_status = '正常';
|
|
|
+ } elseif ($v1['status'] == 2) {
|
|
|
+ $refund_status = '已申报';
|
|
|
+ } elseif ($v1['status'] == 3) {
|
|
|
+ $refund_status = '已退款';
|
|
|
+ }
|
|
|
+ $tk = Dever::db('shop/buy_order_refund')->find(array('order_id'=>$v['id'],'order_goods_id'=>$v1['id']));
|
|
|
+ $refund_cdate = '-';
|
|
|
+ if ($tk) {
|
|
|
+ $refund_cdate = date('Y-m-d H:i',$tk['cdate']);
|
|
|
+ }
|
|
|
+ if ($k1 == 0) {
|
|
|
+ $num = $v['num'];
|
|
|
+ $order_price = round($v['price'],2);
|
|
|
+ $shifu = $shifu;
|
|
|
+ $record_cash = $record_cash;
|
|
|
+ $refund_cash = round($v['refund_cash'],2);
|
|
|
+ } else {
|
|
|
+ $num = 0;
|
|
|
+ $order_price = 0;
|
|
|
+ $shifu = 0;
|
|
|
+ $record_cash = 0;
|
|
|
+ $refund_cash = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ $d = array
|
|
|
+ (
|
|
|
+ $shop_type,
|
|
|
+ $shop['sid'],
|
|
|
+ $shop['name'],
|
|
|
+ $v['order_num'],
|
|
|
+ $goods_info['code']."\t",
|
|
|
+ $goods_info['cunhuo_code']."\t",
|
|
|
+ $goods_info['name'],
|
|
|
+ $sku,
|
|
|
+ $goods_info['tax'],
|
|
|
+
|
|
|
+ round($v1['price'],2),
|
|
|
+ round($v1['num'],2),
|
|
|
+ round($v1['price']*$v1['num'],2),
|
|
|
+
|
|
|
+ $zhuce,
|
|
|
+ $cdate,
|
|
|
+ $cdate,
|
|
|
+ $fadate,
|
|
|
+ $fdate,
|
|
|
+
|
|
|
+ $num,
|
|
|
+ $order_price,
|
|
|
+ $shifu,
|
|
|
+ $record_cash,
|
|
|
+ $goods_status[$v1['status']],
|
|
|
+ $refund_status,
|
|
|
+ $refund_cdate,
|
|
|
+ $refund_cash,
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $address_contact,
|
|
|
+ $address_mobile,
|
|
|
+ $address_info,
|
|
|
+ );
|
|
|
+ $body[] = $d;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!$body) {
|
|
|
+ Dever::alert('此时段没有数据,请重新选择条件');
|
|
|
+ }
|
|
|
+ $file = '代理商兑换订单';
|
|
|
+ return Dever::excelExport($body, $header, $file);
|
|
|
+ }
|
|
|
public function memberGoods_api()
|
|
|
{
|
|
|
$name = Dever::input('name');
|