Commit 19a4fc83 by 朱继来

Merge branch 'zjl_iteration_20200318'

parents 315afce2 dc6ae536
......@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Model\UserSampleApplyModel;
use App\Model\UserSampleInviteModel;
use DB;
use Excel;
......@@ -19,6 +20,7 @@ Class ExportController extends Controller
public function selfSampleExport($request)
{
$UserSampleApplyModel = new UserSampleApplyModel();
$UserSampleInviteModel = new UserSampleInviteModel();
$data = $UserSampleApplyModel->lists($request, 1);
foreach ($data as $k=>$v) {
......@@ -31,10 +33,19 @@ Class ExportController extends Controller
$cellData[$k]['order_sn'] = $v['order_sn'];
$cellData[$k]['goods_id'] = $v['goods_id'];
$cellData[$k]['goods_name'] = $v['goods_name'];
$cellData[$k]['create_time'] = $v['create_time'];
$invite = $UserSampleInviteModel->where('user_id', $v['user_id'])->select('invitee_mobile')->get()->toArray();
if (!empty($invite)) {
$cellData[$k]['invitee'] = implode(',', array_column($invite, 'invitee_mobile'));
} else {
$cellData[$k]['invitee'] = '';
}
$cellData[$k]['create_time'] = $v['create_time'];
}
$headerCell = ['用户ID', '用户账户', '邀请人数', '已申请样片数', '剩余领取次数', '订单ID', '订单编号', '样片ID', '样片名称', '最近一次领取时间'];
$headerCell = ['用户ID', '用户账户', '邀请人数', '已申请样片数', '剩余领取次数', '订单ID', '订单编号', '样片ID', '样片名称', '邀请用户', '最近一次领取时间'];
$fileName ='自营样片领取记录导出'.date('_YmdHis');
$sheetName = '自营样片';
......
......@@ -668,12 +668,12 @@ Class OrderController extends Controller
if ($order_goods_type == 1) {
$file_name = '联营订单导出';
$source_items_id = Config('website.export_joint_source_id');
$headerCell = ['订单ID', '订单编号', 'ERP单号', '京东订单号', '会员账号', '收货人', '下单日期', '下单时间', '客户名称', '平台来源', 'SKUID', '商品型号', '商品分类', '制造商', '供应商', '数量', '单价', '均摊后单价', '商品小计', '币种', '客服', '商品总额', '运费', '附加费', '优惠券', '订单总额', '人民币总额', '付款类型', '订单状态', '发货状态', '收货地址', '发票类型', '发票状态', '发票抬头', '公司注册地址', '公司电话', 'adtags来源', '新用户来源', '取消原因', '推送备注', '是否为测试订单', '是否为新订单', '付款日期', '付款时间'];
$headerCell = ['订单ID', '订单编号', 'ERP单号', '京东订单号', '会员账号', '收货人', '下单日期', '下单时间', '客户名称', '平台来源', 'SKUID', '商品型号', '商品分类', '制造商', '供应商', '币种', '客服', '数量', '单价', '均摊后单价', '商品小计', '费用', '折扣', '商品总额', '运费', '附加费', '优惠券', '订单总额', '人民币总额', '付款类型', '订单状态', '发货状态', '收货地址', '发票类型', '发票状态', '发票抬头', '公司注册地址', '公司电话', 'adtags来源', '新用户来源', '取消原因', '推送备注', '是否为测试订单', '是否为新订单', '付款日期', '付款时间'];
$return_url = '/list';
} else {
$file_name = '自营订单导出';
$source_items_id = Config('website.export_self_source_id');
$headerCell = ['订单ID', '订单编号', 'ERP单号', '京东订单号', '会员账号', '收货人', '下单日期', '下单时间', '客户名称', '平台来源', 'SKUID', '商品型号', '商品分类', '制造商', '供应商', '数量', '单价', '均摊后单价', '商品小计', '币种', '客服', '商品总额', '运费', '附加费', '优惠券', '订单总额', '付款类型', '订单状态', '发货状态', '收货地址', '发票类型', '发票状态', '发票抬头', '公司注册地址', '公司电话', 'adtags来源', '新用户来源', '取消原因', '推送备注', '是否为测试订单', '销售类型', '业务类型', '自采标记', '项目需求描述','收货联系电话', '付款日期', '付款时间'];
$headerCell = ['订单ID', '订单编号', 'ERP单号', '京东订单号', '会员账号', '收货人', '下单日期', '下单时间', '客户名称', '平台来源', 'SKUID', '商品型号', '商品分类', '制造商', '供应商', '币种', '客服', '数量', '单价', '均摊后单价', '商品小计', '费用', '折扣', '商品总额', '运费', '附加费', '优惠券', '订单总额', '付款类型', '订单状态', '发货状态', '收货地址', '发票类型', '发票状态', '发票抬头', '公司注册地址', '公司电话', 'adtags来源', '新用户来源', '取消原因', '推送备注', '是否为测试订单', '销售类型', '业务类型', '自采标记', '项目需求描述','收货联系电话', '付款日期', '付款时间'];
$return_url = '/self_order';
}
......
......@@ -249,7 +249,7 @@ class OrderModel extends Model
})
->where('it.status', 1)
->where('o.order_goods_type', '=', $map['order_goods_type'])
->select('o.order_id', 'o.order_sn', 'o.order_type', 'o.order_pay_type', 'o.order_goods_type', 'o.order_source', 'o.create_time', 'o.status', 'o.order_amount', 'o.sale_type', 'o.currency', 'o.sale_id', 'o.cancel_reason', 'o.advance_pay_time', 'o.pay_time', 'it.goods_id', 'it.goods_name', 'it.goods_number', 'it.goods_price', 'it.single_pre_price', 'it.brand_name', 'it.supplier_name', 'it.goods_class', 'it.self_supplier_type', 'i.tax_title', 'i.inv_type', 'i.invoice_status', 'i.tax_title', 'i.company_address', 'i.company_phone', 'i.tax_no', 'i.bank_name', 'i.bank_account', 'u.user_id', 'u.mobile', 'u.email', 'u.client_source', 'u.is_new', 'u.is_test', 'oe.erp_sn', 'oe.order_type as extend_order_type', 'oe.send_remark', 'oe.is_new as is_new_order', 'oe.business_type', 'oe.jd_order_id', 'oe.exchange_rate', 'oe.sample_demand_desc')
->select('o.order_id', 'o.order_sn', 'o.order_type', 'o.order_pay_type', 'o.order_goods_type', 'o.order_source', 'o.create_time', 'o.status', 'o.order_amount', 'o.sale_type', 'o.currency', 'o.sale_id', 'o.cancel_reason', 'o.advance_pay_time', 'o.pay_time', 'it.goods_id', 'it.goods_name', 'it.goods_number', 'it.goods_price', 'it.single_pre_price', 'it.brand_name', 'it.supplier_name', 'it.goods_class', 'it.self_supplier_type', 'it.extra_price', 'it.goods_discount_amount', 'i.tax_title', 'i.inv_type', 'i.invoice_status', 'i.tax_title', 'i.company_address', 'i.company_phone', 'i.tax_no', 'i.bank_name', 'i.bank_account', 'u.user_id', 'u.mobile', 'u.email', 'u.client_source', 'u.is_new', 'u.is_test', 'oe.erp_sn', 'oe.order_type as extend_order_type', 'oe.send_remark', 'oe.is_new as is_new_order', 'oe.business_type', 'oe.jd_order_id', 'oe.exchange_rate', 'oe.sample_demand_desc')
->groupBy('it.rec_id')
->orderBy('o.create_time', 'DESC')
// ->get()
......@@ -348,7 +348,10 @@ class OrderModel extends Model
// 获取所有价格
$OrderPriceModel = new OrderPriceModel();
$order_price = $OrderPriceModel->whereIn('order_id', $all_order_id)->select('order_id', 'price_type', 'price')->get()->keyBy('order_id')->toArray();
// $order_price = $OrderPriceModel->whereIn('order_id', $all_order_id)->select('order_id', 'price_type', 'price')->get()->keyBy('order_id')->toArray();
$order_price = $OrderPriceModel->whereIn('order_id', $all_order_id)->select('order_id', 'price_type', 'price')->get()->keyBy(function ($item) {
return strtoupper($item['order_id'].'.'.$item['price_type']);
})->toArray();
// 获取用户公司名称
$UserCompanyModel = new UserCompanyModel();
......@@ -383,16 +386,18 @@ class OrderModel extends Model
$tmp[$i]['goods_id'] = $order[$i]['goods_id'];
// 自营商品名称换成商品型号
$tmp[$i]['goods_name'] = $order[$i]['order_goods_type'] == 1 ? $order[$i]['goods_name'] : $this->getGoodsName($order[$i]['goods_id']);
$tmp[$i]['goods_class'] = $order[$i]['goods_class'];
$tmp[$i]['brand_name'] = $order[$i]['brand_name'];
$tmp[$i]['supplier_name'] = $order[$i]['supplier_name'];
$tmp[$i]['goods_number'] = $order[$i]['goods_number'];
$tmp[$i]['goods_price'] = $order[$i]['goods_price'];
$tmp[$i]['single_pre_price'] = $order[$i]['single_pre_price'];
$tmp[$i]['goods_amount'] = $order[$i]['goods_number'] * $order[$i]['goods_price'];
$tmp[$i]['currency'] = $order[$i]['currency'] == 1 ? 'RMB' : 'USD';
$tmp[$i]['sale_name'] = isset($sales[$order[$i]['sale_id']]) ? $sales[$order[$i]['sale_id']] : ''; // 推送业务员
$tmp[$i]['goods_name'] = $order[$i]['order_goods_type'] == 1 ? $order[$i]['goods_name'] : $this->getGoodsName($order[$i]['goods_id']);
$tmp[$i]['goods_class'] = $order[$i]['goods_class'];
$tmp[$i]['brand_name'] = $order[$i]['brand_name'];
$tmp[$i]['supplier_name'] = $order[$i]['supplier_name'];
$tmp[$i]['currency'] = $order[$i]['currency'] == 1 ? 'RMB' : 'USD';
$tmp[$i]['sale_name'] = isset($sales[$order[$i]['sale_id']]) ? $sales[$order[$i]['sale_id']] : ''; // 推送业务员
$tmp[$i]['goods_number'] = $order[$i]['goods_number'];
$tmp[$i]['goods_price'] = $order[$i]['goods_price'];
$tmp[$i]['single_pre_price'] = $order[$i]['single_pre_price'];
$tmp[$i]['goods_amount'] = $order[$i]['goods_number'] * $order[$i]['goods_price'];
$tmp[$i]['extra_price'] = $order[$i]['extra_price']; // 费用
$tmp[$i]['goods_discount_amount'] = $order[$i]['goods_discount_amount']; // 折扣
if ($i > 0 && $order[$i]['order_id'] == $order[$i-1]['order_id']) {
$tmp[$i]['goods_sum'] = '';
......@@ -405,12 +410,10 @@ class OrderModel extends Model
$tmp[$i]['rmb_amount'] = ''; // 人民币总额
}
} else {
$price = isset($order_price[$order[$i]['order_id']]) ? $order_price[$order[$i]['order_id']] : false;
$tmp[$i]['goods_sum'] = $price && $price['price_type'] == 1 ? $price['price'] : 0;
$tmp[$i]['shipping_fee'] = $price && $price['price_type'] == 3 ? $price['price'] : 0;
$tmp[$i]['extra_fee'] = $price && $price['price_type'] == 2 ? $price['price'] : 0;
$tmp[$i]['coupon'] = $price && $price['price_type'] == -4 ? $price['price'] : 0;
$tmp[$i]['goods_sum'] = isset($order_price[$order[$i]['order_id'].'.1']) ? $order_price[$order[$i]['order_id'].'.1']['price'] : 0;
$tmp[$i]['shipping_fee'] = isset($order_price[$order[$i]['order_id'].'.3']) ? $order_price[$order[$i]['order_id'].'.3']['price'] : 0;
$tmp[$i]['extra_fee'] = isset($order_price[$order[$i]['order_id'].'.2']) ? $order_price[$order[$i]['order_id'].'.2']['price'] : 0;
$tmp[$i]['coupon'] = isset($order_price[$order[$i]['order_id'].'.-4']) ? $order_price[$order[$i]['order_id'].'.-4']['price'] : 0;
$tmp[$i]['order_amount'] = $order[$i]['order_amount'];
if ($order[$i]['order_goods_type'] == 1) {
......
......@@ -110,7 +110,13 @@ class UserSampleApplyModel extends Model
// 获取指定字段的总数
public function getSampleApplySum($user_id, $field='apply_num')
{
return $this->where('user_id', $user_id)->sum($field);
return $this->from('lie_user_sample_apply as s')
->join('lie_order as o', 's.order_id', '=', 'o.order_id')
->where('s.user_id', '=', $user_id)
->where('o.status', '<>', '-1')
->sum('apply_num');
// return $this->where('user_id', $user_id)->sum($field);
}
// 获取指定用户申请的样片消耗总人数
......
......@@ -804,6 +804,8 @@
var cart_ids = [];
if (len > 0) {
var buyer = '';
// 购物车列表
for (var i = 0; i < len; i++) {
html += '<tr data-cid="'+list[i].cart_id+'" data-type="'+list[i].type+'" min_buy="'+list[i].min_buy+'">'+
......@@ -823,9 +825,14 @@
if (goods_type == 1) {
html += '<td>'+list[i].supplier_name+'</td>';
buyer = list[i].buyer_id != '0' ? list[i].buyer_id : '';
html += '<td>'+buyer+'</td>';
html += '<td>'+list[i].batch+'</td>';
}
html += '<td><a class="btn btn-danger btn-xs remove-goods">删除</a></td>'+
html += '<td><a class="btn btn-danger btn-xs remove-goods">删除</a></td>'+
'</tr>';
cart_ids.push(list[i].cart_id); // 购物车ID集合
......
......@@ -339,14 +339,16 @@
<thead>
<tr>
<th width="5%">序号</th>
<th width="15%">SKUID</th>
<th width="20%">商品名称</th>
<th width="10%">SKUID</th>
<th width="15%">商品名称</th>
<th width="10%">制造商</th>
<th width="10%">采购数量</th>
<th width="10%">采购单价</th>
<th width="10%">小计</th>
<th width="10%">货期</th>
<th width="10%">供应商</th>
<th width="8%">采购数量</th>
<th width="7%">采购单价</th>
<th width="7%">小计</th>
<th width="7%">货期</th>
<th width="7%">供应商</th>
<th width="7%">采购员</th>
<th width="10%">批次</th>
<th width="5%">操作</th>
</tr>
</thead>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment