Commit 1b257dd7 authored by 谢希宇's avatar 谢希宇

Aidea product update by Strive Date 2020-11-27

parent 1fdef6e4
......@@ -22,7 +22,6 @@ import com.cftech.core.util.Constants;
import com.cftech.core.util.MpTokenUtil;
import com.cftech.core.util.StringUtils;
import com.cftech.core.util.SystemConfig;
import com.cftech.member.model.Member;
import com.cftech.member.service.MemberService;
import com.cftech.order.model.Order;
import com.cftech.order.service.OrderService;
......
package com.cftech.order.job;
import com.cftech.accounts.model.SysJob;
import com.cftech.accounts.service.JobService;
import com.cftech.core.sql.Conds;
import com.cftech.core.util.Constants;
import com.cftech.core.util.SpringContextHolder;
import com.cftech.core.util.SystemConfig;
import com.cftech.order.model.Order;
import com.cftech.order.service.OrderService;
import com.cftech.orderdetail.service.OrderDetailsService;
import com.cftech.orderdetail.service.impl.OrderDetailsServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* 订单过期提醒
* Created by 16444 on 2020/11/24.
*/
@Slf4j
public class OrderExpiredRemindJob implements Job {
/**
* @param context 通过JobExecutionContext对象访问到Quartz运行时候的环境以及Job本身的数据明细
* @throws JobExecutionException
*/
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
boolean isCluster = Boolean.valueOf(SystemConfig.p.getProperty("quartz.isCluster"));
if (!isCluster) {
return;
}
Conds orderConds = new Conds();
orderConds.equal("o.del_flag", Constants.DEL_FLAG_0);
orderConds.equal("o.status", "1");//待付款订单
OrderService orderService = SpringContextHolder.getBean(OrderService.class);
List<Order> orders = orderService.fetchSearchByPage(orderConds, null, 0, 0);
for (Order ord: orders) {
Date orderTime = ord.getOrderTime();//确认时间
Calendar calendar = Calendar.getInstance();
calendar.setTime(orderTime);
calendar.add(Calendar.MINUTE, 30);
orderTime = calendar.getTime();
//超过半小时
if (orderTime.compareTo(new Date()) < 0 ) {
ord.setStatus("5");
ord.setCancelTime(new Date());
ord.setOrderCancel("订单超时取消");
orderService.update(ord);
}
}
//获得明细数据
JobDataMap jobInfo = context.getJobDetail().getJobDataMap();
String id = jobInfo.get("uid") == null ? "" : jobInfo.getString("uid");//这个也是ID主键
log.info("任务ID:" + id);
//执行更新操作
if (context.getNextFireTime() != null) {
log.info("订单半小时未付款过期任务:下次执行时间=====" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(context.getNextFireTime()) + "==============");
} else {
JobService jobService = SpringContextHolder.getBean(JobService.class);
SysJob sysJob = new SysJob();
sysJob.setJobuid(id);
sysJob.setStatus("0");
jobService.updateStatus(sysJob);
log.info("订单半小时未付款过期任务,已执行完成");
}
}
}
......@@ -454,6 +454,24 @@ public class OrderController {
return rtnJson;
}
@RequestMapping("/setOrderRemind")
@ResponseBody
public JSONObject setOrderRemind(Long id, String option, HttpServletRequest request) {
JSONObject rtnJson = new JSONObject();
//Integer integer = orderService.updateStatus(id, status, orderCancel);
//设置已付款
// if (integer > 0){
// //线下付款成功
// if (StringUtils.equals(status, "2")) {
// sendQyWechatMassage(id);
// }
// rtnJson.put("errorNo","0");
// return rtnJson;
// }
rtnJson.put("errorNo","1");
return rtnJson;
}
/**
* 推送企业微信消息
*/
......
......@@ -119,11 +119,11 @@
<div class="panel-body">
<div class="form-group form-md-line-input col-xs-5">
<label>会员名称</label>
<label>粉丝名称</label>
<input type="text"
class="form-control" id="memberName" name="memberName"
maxlength="500" placeholder="会员名称"
value="$!{data.memberName}" readonly>
class="form-control" id="nickName" name="nickName"
maxlength="500" placeholder="粉丝名称"
value="$!{data.nickName}" readonly>
</div>
<div class="form-group form-md-line-input col-xs-5">
......
......@@ -60,12 +60,12 @@
<section class="content-header">
<h1>
顺丰物流运单管理
<small>顺丰物流运单</small>
物流管理
<small>顺丰物流管理</small>
</h1>
<ol class="breadcrumb">
<li><a><i class="fa fa-dashboard"></i>首页</a></li>
<li><a class="active">顺丰物流运单管理列表</a></li>
<li><a class="active">顺丰物流管理列表</a></li>
</ol>
</section>
......@@ -110,11 +110,17 @@
<td hidden="true">Id</td>
<th>物流单编码</th>
<th>顺丰运单号</th>
<th>会员名称</th>
<th>订单编码</th>
<th>咨询单编码</th>
<th>粉丝昵称</th>
<th>OpenId</th>
<th>联系人名称</th>
<th>联系人手机号</th>
<th>物流状态</th>
<th>订单员</th>
<th>收派状态</th>
<th>创建时间</th>
<th>发件时间</th>
<th>收件时间</th>
<th>操作</th>
</tr>
</thead>
......@@ -167,8 +173,8 @@
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
return year + "-" + month + "-" + date + " " + hour + ":"
+ minute + ":" + second;
return year + "-" + (month <= 9 ? "0" + month : month) + "-" + (date <= 9 ? "0" + date : date) + " " + (hour <= 9 ? "0" + hour : hour) + ":"
+ (minute <= 9 ? "0" + minute : minute) + ":" + (second <= 9 ? "0" + second : second);
}
function seachTable() {
......@@ -218,30 +224,54 @@
"mData": "waybillNo"
},
{
"mData": "memberName"
"mData": "orderCode"
},
{
"mData": "contact"
"mData": "consultSheetCode"
},
{
"mData": "mobile"
"mData": "nickName"
},
{
"mData": "status"
"mData": "openId"
},
{
"mData": "createTime"
"mData": "contact",
"mRender": function (a, b, c, d) {
if (a) {
return a.slice(0, 1) + '*' + a.slice(2, 3);
} else {
return null;
}
}
},
{
"mData": "id"
}],
"aoColumnDefs": [
{ // set default column settings
'visible': false,
'targets': [0]
"mData": "mobile",
"mRender": function (a, b, c, d) {
if (a) {
return a.slice(0, 3) + '****' + a.slice(7);
} else {
return null;
}
}
},
{
"mData": "storageManageName"
},
{
"mData": "filterResult",
"mRender": function (a, b, c, d) {
switch (a) {
case "1":
return "人工确认";
case "2":
return "可收派";
case "3":
return "不可收派";
}
}
},
{
"aTargets": [7],
"mData": "createTime",
"mRender": function (a, b, c, d) {
return formatDates(a, "yyyy-MM-dd HH:mm:ss");
......@@ -249,18 +279,47 @@
}
},
{
"aTargets": [8],
"mData": "createTime",
"mData": "sendExpressDate",
"mRender": function (a, b, c, d) {
let time = formatDates(a);
if (time.indexOf("1970") == -1) {
return formatDates(a, "yyyy-MM-dd HH:mm:ss");
}
return "";
}
},
{
"mData": "acceptExpressDate",
"mRender": function (a, b, c, d) {
let time = formatDates(a);
if (time.indexOf("1970") == -1) {
return formatDates(a, "yyyy-MM-dd HH:mm:ss");
}
return "";
}
},
{
"mData": "id"
}],
"aoColumnDefs": [
{ // set default column settings
'visible': false,
'targets': [0]
},
{
"aTargets": [14],
"mData": "id",
"mRender": function (a, b, c, d) {
var html = '#if($shiro.hasPermission("qy:waybill:edit"))';
html += '<div class="btn-group">\n' +
html += '<div class="btn-group" style="min-width: 100px;">\n' +
'<button type="button" class="btn btn-success btn-flat">操作</button>\n' +
'<button type="button" class="btn btn-success btn-flat dropdown-toggle" data-toggle="dropdown">\n' +
' <span class="caret"></span>\n' +
' <span class="sr-only">Toggle Dropdown</span>\n' +
'</button>\n' +
'<ul class="dropdown-menu" role="menu">\n';
'<ul class="dropdown-menu" role="menu" style="min-width: 100px;">\n';
html += '<li><a href="#springUrl("/a/waybill/form?id=' + a + '")">查看</a></li>';
html += '<li><a href="#springUrl("/a/waybill/orderPrinterBill?orderId=' + c.orderId + '")">打印物流单</a></li>';
html += '</ul>';
html += '#end';
return html;
......
......@@ -35,6 +35,8 @@
<result column="update_by" property="updateBy"/>
<result column="route_des" property="routeDes"/>
<result column="filter_result" property="filterResult"/>
<result column="dest_code" property="destCode"/>
<result column="origin_code" property="originCode"/>
</resultMap>
<sql id="sqlWhere">
......@@ -95,7 +97,9 @@
description,
create_by,
update_by,
filter_result
filter_result,
dest_code,
origin_code
</sql>
<sql id="insertSqlColumns">
......@@ -130,7 +134,9 @@
create_by,
update_by,
route_des,
filter_result
filter_result,
dest_code,
origin_code
</sql>
......@@ -173,15 +179,64 @@
#{createBy, jdbcType=BIGINT},
#{updateBy, jdbcType=BIGINT},
#{routeDes, jdbcType=VARCHAR},
#{filterResult, jdbcType=VARCHAR}
#{filterResult, jdbcType=VARCHAR},
#{destCode, jdbcType=VARCHAR},
#{originCode, jdbcType=VARCHAR}
)
</insert>
<select id="fetchById" parameterType="java.lang.Long" resultMap="resultMap">
<select id="fetchById" parameterType="java.lang.Long" resultType="com.cftech.waybill.model.Waybill">
SELECT
<include refid="sqlColumns"/>
t.id,
t.consult_id consultId,
t.order_id orderId,
t.number,
t.member_id memberId,
t.open_id openId,
t.storage_manage storageManage,
t.waybill_no waybillNo,
t.language,
t.monthly_card monthlyCard,
t.express_type_id expressTypeId,
t.temperature_range temperatureRange,
t.contact,
t.mobile,
t.province,
t.city,
t.county,
t.address,
t.address_id addressId,
t.send_express_date sendExpressDate,
t.accept_express_date acceptExpressDate,
t.waybill_remark waybillRemark,
t.accounts_id accountsId,
t.del_flag delFlag,
t.status,
t.create_time createTime,
t.update_time updateTime,
t.description,
t.create_by,
t.update_by,
o.number orderCode,
od.drugs_num drugsNum,
od.drugs_name drugsName,
od.drugs_code drugsCode,
od.price,
AES_DECRYPT(f.nickname, 'aideakey') nickName,
cs.consult_id consultSheetCode,
qyu.name storageManageName,
t.route_des routeDes,
t.filter_result filterResult,
t.dest_code destCode,
t.origin_code originCode
FROM t_aidea_waybill t
WHERE t.id=#{id}
LEFT JOIN t_aidea_consult_sheet cs ON cs.id = t.consult_id
LEFT JOIN t_order o ON t.order_id = o.id
LEFT JOIN t_order_details od ON o.id = od.order_id
LEFT JOIN wx_mp_fanss f ON f.openid = t.open_id AND f.delflag = '0'
LEFT JOIN user u ON u.id = t.storage_manage
LEFT JOIN t_qyuser qyu ON qyu.id = u.userid
WHERE t.id = #{id}
</select>
<select id="fetchByWayBillId" parameterType="java.lang.Long" resultType="com.cftech.waybill.model.Waybill">
......@@ -205,14 +260,14 @@
t.county,
t.address,
t.address_id addressId,
DATE_FORMAT(t.send_express_date, '%Y-%m-%d %H:%i') sendExpressDateStr,
DATE_FORMAT(t.accept_express_date, '%Y-%m-%d %H:%i') acceptExpressDateStr,
t.send_express_date sendExpressDate,
t.accept_express_date acceptExpressDate,
t.waybill_remark waybillRemark,
t.accounts_id accountsId,
t.del_flag delFlag,
t.status,
t.create_time createTimeStr,
t.update_time updateTimeStr,
t.create_time createTime,
t.update_time updateTime,
t.description,
t.create_by,
t.update_by,
......@@ -221,23 +276,31 @@
od.drugs_name drugsName,
od.drugs_code drugsCode,
od.price,
AES_DECRYPT(m.name, 'aideakey') memberName,
AES_DECRYPT(f.nickname, 'aideakey') nickName,
cs.consult_id consultSheetCode,
qyu.name storageManageName,
route_des routeDes,
filter_result filterResult
t.route_des routeDes,
t.filter_result filterResult,
t.dest_code destCode,
t.origin_code originCode
FROM t_aidea_waybill t
LEFT JOIN t_aidea_consult_sheet cs ON cs.id = t.consult_id
LEFT JOIN t_order o ON t.order_id = o.id
LEFT JOIN t_order_details od ON o.id = od.order_id
LEFT JOIN wx_mp_member m ON t.member_id = m.id
LEFT JOIN wx_mp_fanss f ON f.openid = t.open_id AND f.delflag = '0'
LEFT JOIN user u ON u.id = t.storage_manage
LEFT JOIN t_qyuser qyu ON u.id = u.userid
WHERE t.id=#{id}
LEFT JOIN t_qyuser qyu ON qyu.id = u.userid
WHERE t.id = #{id}
</select>
<select id="count" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT COUNT(1) FROM t_aidea_waybill t
LEFT JOIN t_aidea_consult_sheet cs ON cs.id = t.consult_id
LEFT JOIN t_order o ON t.order_id = o.id
LEFT JOIN t_order_details od ON o.id = od.order_id
LEFT JOIN wx_mp_fanss f ON f.openid = t.open_id AND f.delflag = '0'
LEFT JOIN user u ON u.id = t.storage_manage
LEFT JOIN t_qyuser qyu ON qyu.id = u.userid
<include refid="sqlWhere"/>
</select>
......@@ -262,14 +325,14 @@
t.county,
t.address,
t.address_id addressId,
DATE_FORMAT(t.send_express_date, '%Y-%m-%d %H:%i') sendExpressDateStr,
DATE_FORMAT(t.accept_express_date, '%Y-%m-%d %H:%i') acceptExpressDateStr,
t.send_express_date sendExpressDate,
t.accept_express_date acceptExpressDate,
t.waybill_remark waybillRemark,
t.accounts_id accountsId,
t.del_flag delFlag,
t.status,
DATE_FORMAT(t.create_time, '%Y-%m-%d %H:%i') createTimeStr,
DATE_FORMAT(t.update_time, '%Y-%m-%d %H:%i') updateTimeStr,
t.create_time createTime,
t.update_time updateTime,
t.description,
t.create_by,
t.update_by,
......@@ -278,18 +341,20 @@
od.drugs_name drugsName,
od.drugs_code drugsCode,
od.price,
AES_DECRYPT(m.name, 'aideakey') memberName,
AES_DECRYPT(f.nickname, 'aideakey') nickName,
cs.consult_id consultSheetCode,
qyu.name storageManageName,
route_des routeDes,
filter_result filterResult
t.route_des routeDes,
t.filter_result filterResult,
t.dest_code destCode,
t.origin_code originCode
FROM t_aidea_waybill t
LEFT JOIN t_aidea_consult_sheet cs ON cs.id = t.consult_id
LEFT JOIN t_order o ON t.order_id = o.id
LEFT JOIN t_order_details od ON o.id = od.order_id
LEFT JOIN wx_mp_member m ON t.member_id = m.id
LEFT JOIN wx_mp_fanss f ON f.openid = t.open_id AND f.delflag = '0'
LEFT JOIN user u ON u.id = t.storage_manage
LEFT JOIN t_qyuser qyu ON u.id = u.userid
LEFT JOIN t_qyuser qyu ON qyu.id = u.userid
<include refid="sqlWhere"/>
<if test="sort!=null">ORDER BY ${sort.param} ${sort.type}</if>
<if test="limit>0">limit #{offset},#{limit}</if>
......@@ -389,7 +454,13 @@
route_des = #{routeDes, jdbcType=BIGINT},
</if>
<if test="filterResult != null">
filter_result = #{filterResult, jdbcType=BIGINT},
filter_result = #{filterResult, jdbcType=VARCHAR},
</if>
<if test="originCode != null">
origin_code = #{originCode, jdbcType=VARCHAR},
</if>
<if test="destCode != null">
dest_code = #{destCode, jdbcType=VARCHAR},
</if>
</set>
where id=#{id,jdbcType=BIGINT}
......
......@@ -18,26 +18,29 @@ public class Waybill implements Serializable {
/* 主键id */
private Long id;
/* 咨询单Id */
private Long consultId;
/* 订单Id */
private Long orderId;
/* 物流单编码 */
@ExportConfig(value = "物流单编码", width = 100, showLevel = 1)
@ExportConfig(value = "物流单编码", width = 120, showLevel = 1)
private String number;
/* 会员Id */
/* 顺丰运单号 */
@ExportConfig(value = "顺丰运单号", width = 120, showLevel = 1)
private String waybillNo;
/* 会员Id */
private String memberId;
/* 粉丝Id */
@ExportConfig(value = "粉丝OpneId", width = 120, showLevel = 1)
private String openId;
/* 仓管员Id */
private String storageManage;
/* 顺丰运单号 */
@ExportConfig(value = "顺丰运单号", width = 100, showLevel = 1)
private String waybillNo;
/* 语言 */
private String language;
/* 顺丰月结卡号 */
......@@ -46,33 +49,31 @@ public class Waybill implements Serializable {
/**
* 会员名称
*/
@ExportConfig(value = "会员名称", width = 100, showLevel = 1)
private String memberName;
//@ExportConfig(value = "会员名称", width = 100, showLevel = 1)
//private String memberName;
@ExportConfig(value = "联系人", width = 100, showLevel = 1)
/* 联系人 */
@ExportConfig(value = "联系人", width = 120, showLevel = 1)
private String contact;
/* 联系电话 */
@ExportConfig(value = "联系人手机号", width = 120, showLevel = 1)
private String mobile;
/* 快件产品类型 */
private String expressTypeId;
/* 温度范围控制 1:冷藏 3:冷冻 */
private String temperatureRange;
/* 联系人 */
/* 联系电话 */
@ExportConfig(value = "联系电话", width = 100, showLevel = 1)
private String mobile;
/* 省份 */
/* 省份 */
private String province;
/* 城市 */
private String city;
/* 县/区级行政区名称 */
private String county;
/* 地址Id */
private String addressId;
/* 详细地址 */
private String address;
......@@ -87,7 +88,6 @@ public class Waybill implements Serializable {
/* 删除标识 */
private boolean delFlag;
/* 状态 */
@ExportConfig(value = "物流状态", width = 100, showLevel = 1)
private String status;
/* 创建时间 */
private Date createTime;
......@@ -108,23 +108,35 @@ public class Waybill implements Serializable {
/**
* 筛单结果
*/
private String filterResult;
@ExportConfig(value = "筛单结果", width = 120, showLevel = 1)
private String filterResult;// 筛单结果 1:人工确认; 2:可收派; 3:不可以收派
private String originCode;//原寄地代码
private String destCode;//收件地代码
private String shippercode;//寄件人邮政编码
/**
* 非数据库字段
*/
@ExportConfig(value = "订单编码", width = 120, showLevel = 1)
private String orderCode;//订单编码
private String drugsNum;//商品数量
private String drugsName;//商品名称
private String drugsCode;//商品编码
private String price;//价格
@ExportConfig(value = "咨询单编码", width = 120, showLevel = 1)
private String consultSheetCode;//咨询单编码
@ExportConfig(value = "订单员名称", width = 120, showLevel = 1)
private String storageManageName;//仓管员名称
private String sendExpressDateStr;
private String acceptExpressDateStr;
private String createTimeStr;
private String updateTimeStr;
@ExportConfig(value = "粉丝昵称", width = 120, showLevel = 1)
private String nickName;//粉丝昵称
public Waybill() {
this.delFlag = false;
......
......@@ -26,4 +26,12 @@ public interface WaybillService extends GenericService<Waybill> {
* @param orderId
*/
JSONObject orderSendOutForWaybill(HttpServletRequest request, Long orderId);
/**
* 调用顺分sdk打印面单
* @param request
* @param orderId
* @return
*/
JSONObject orderPrinterBill(HttpServletRequest request, Long orderId);
}
......@@ -21,10 +21,7 @@ import com.cftech.waybill.service.WaybillService;
import com.cftech.core.generic.GenericDao;
import com.cftech.core.generic.GenericServiceImpl;
import com.cftech.core.sql.Conds;
import com.cftech.waybill.utils.CloseableHttpEntity;
import com.cftech.waybill.utils.ExpressOrderInfoUtils;
import com.cftech.waybill.utils.FqConstants;
import com.cftech.waybill.utils.FqHttpUtils;
import com.cftech.waybill.utils.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -34,7 +31,9 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 顺丰物流运单ServiceImpl
......@@ -116,6 +115,7 @@ public class WaybillServiceImpl extends GenericServiceImpl<Waybill> implements W
//生成物流数据
Waybill waybill = new Waybill();
waybill.setAccountsId(accountsId);
waybill.setNumber(codingruleUtils.getNumber(accountsId, Waybill.class.getName()));
waybill.setConsultId(order.getConsultId());
waybill.setOpenId(order.getOpenid());
......@@ -155,6 +155,8 @@ public class WaybillServiceImpl extends GenericServiceImpl<Waybill> implements W
String originCode = msgData.getString("originCode");//原寄地区域代码,可用于顺丰电子运单标签打印
String destCode = msgData.getString("destCode");//目的地区域代码,可用于顺丰电子运单标签打
String filterResult = msgData.getString("filterResult");//筛单结果
waybill.setOriginCode(originCode);
waybill.setDestCode(destCode);
waybill.setFilterResult(filterResult);
JSONArray waybillNoInfoList = msgData.getJSONArray("waybillNoInfoList");//顺丰运单号
......@@ -162,6 +164,7 @@ public class WaybillServiceImpl extends GenericServiceImpl<Waybill> implements W
JSONObject obj = waybillNoInfoList.getJSONObject(i);
if (obj.getInteger("waybillType") == 1) {
waybill.setWaybillNo(obj.getString("waybillNo"));//顺丰运单号
order.setCourierNumber(obj.getString("waybillNo"));
}
}
......@@ -174,10 +177,12 @@ public class WaybillServiceImpl extends GenericServiceImpl<Waybill> implements W
}
waybill.setWaybillRemark(msgData.getString("remark"));//不可派发原因
waybillMapper.save(waybill);
orderService.save(order);
retObj.put("errorNo", 0);
retObj.put("errorMsg", " 成功 ");
retObj.put("errorMsg", "下单接口调用成功");
return retObj;
}
}
......@@ -195,5 +200,66 @@ public class WaybillServiceImpl extends GenericServiceImpl<Waybill> implements W
return retObj;
}
@Override
@Transactional
public JSONObject orderPrinterBill(HttpServletRequest request, Long orderId) {
JSONObject retObj = new JSONObject();
Long accountsId = UserUtils.getmpaccounts(request);
try {
if (orderId == null) {
retObj.put("errorNo", 1);
retObj.put("errorMsg", "Request Params Is Null ! ");
return retObj;
}
//获取订单
Conds orderConds = new Conds();
orderConds.equal("o.del_flag", Constants.DEL_FLAG_0);
orderConds.equal("o.id", orderId);
List<Order> orders = orderService.fetchSearchByPage(orderConds, null, 0, 0);
if (orders == null || orders.size() != 1) {
retObj.put("errorNo", 1);
retObj.put("errorMsg", " 订单不存在 ! ");
return retObj;
}
Order order = orders.get(0);
Conds detailConds = new Conds();
detailConds.equal("d.del_flag", Constants.DEL_FLAG_0);
detailConds.equal("o.id", orderId);
List<OrderDetails> odets = orderDetailsService.fetchSearchByPage(detailConds, null, 0, 0);
if (odets == null || odets.size() == 0) {
retObj.put("errorNo", 1);
retObj.put("errorMsg", " 订单明细不存在 ! ");
return retObj;
}
//生成物流数据
Conds billConds = new Conds();
billConds.equal("t.del_flag", Constants.DEL_FLAG_0);
billConds.equal("t.order_id", order.getId());
Map<String, Object> params = new HashMap<>();
params.put("conds", billConds);
List<Waybill> waybillList = waybillMapper.fetchSearchByPage(params);
if (waybillList == null || waybillList.size() <=0) {
retObj.put("errorNo", 1);
retObj.put("errorMsg", " 物流数据不存在 ! ");
return retObj;
}
Waybill waybill = waybillList.get(0);
//调用接口
JSONObject result = ExpressOrderInfoUtils.generateBillPrinterObj(order, odets, waybill);
JSONArray arr = new JSONArray();
arr.add(result);
BillPrinterUtils.executePrinter(arr.toString());
} catch (Exception e) {
log.error("待用打印服务出错");
e.getMessage();
} finally {
}
return null;
}
}
\ No newline at end of file
package com.cftech.waybill.utils;
import com.sf.util.Base64ImageTools;
import lombok.extern.slf4j.Slf4j;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 顺丰面单打印工具类
* Created by 16444 on 2020/11/26.
*/
@Slf4j
public class BillPrinterUtils {
private static boolean TOP_LOGO = true;
/**
* 打印方法
* @return
*/
public static boolean executePrinter(String printStr) {
String link = FqConstants.TWO_UNITED_150;
try {
link = isPrinterLogo(link, true);
URL url = new URL(link);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setUseCaches(false);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json;charset=utf-8");
//connection.setRequestProperty("Content-Type", "text/plain;charset=utf-8");
connection.setConnectTimeout(5000);
connection.setReadTimeout(3 * 5000);
connection.getOutputStream().write(printStr.getBytes());
connection.getOutputStream().flush();
connection.getOutputStream().close();
InputStream in = connection.getInputStream();
BufferedReader inReader = new BufferedReader(new InputStreamReader(in, "utf-8"));
String y = "";
String strImg = "";
while ((y=inReader.readLine()) != null) {
strImg = y.substring(y.indexOf("[")+1, y.length()-"]".length()-1);
if(strImg.startsWith("\"")){
strImg = strImg.substring(1, strImg.length());
}
if(strImg.endsWith("\"")){
strImg = strImg.substring(0, strImg.length()-1);
}
}
//去掉换行符
strImg = strImg.replace("\\n", "");
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd-HHmmss");
String dateStr = format.format(new Date());
List<String> files = new ArrayList<>();
if(strImg.contains("\",\"")){
//如子母单及签回单需要打印两份或者以上
String[] arr = strImg.split("\",\"");
/**输出图片到本地 支持.jpg、.png格式**/
for(int i = 0; i < arr.length; i++) {
String fileName = "D:\\qiaoWay"+dateStr+"-"+i+".jpg";
Base64ImageTools.generateImage(arr[i].toString(), fileName);
files.add(fileName);
}
}else{
String fileName = "D:\\qiaoWaybill"+dateStr+".jpg";
Base64ImageTools.generateImage(strImg, fileName);
files.add(fileName);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
log.info("调用丰密订单打印方法");
}
return true;
}
/**
* 是否打印logo
* V2.0/V3.0模板顶部是带logo的 V2.1/V3.1顶部不带logo
* @param url
* @return
*/
public static String isPrinterLogo(String url, boolean TOP_LOGO) {
if (url.contains("V2.0") && TOP_LOGO) {
url = url.replace("V2.0", "V2.1");
}
if (url.contains("V3.0") && TOP_LOGO){
url = url.replace("V3.0", "V3.1");
}
if (url.contains("V2.8.0") && TOP_LOGO) {
url = url.replace("V2.8.0", "V2.8.1");
}
System.out.println(url);
return url;
}
}
......@@ -3,6 +3,7 @@ package com.cftech.waybill.utils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.cftech.core.util.StringUtils;
import com.cftech.core.util.SystemConfig;
import com.cftech.order.model.Order;
import com.cftech.orderdetail.model.OrderDetails;
import com.cftech.waybill.model.Waybill;
......@@ -29,6 +30,91 @@ public class ExpressOrderInfoUtils {
private static final String payMethod = "1";//寄方付
public static JSONObject generateBillPrinterObj(Order order, List<OrderDetails> orderDetails, Waybill waybillObj) {
JSONObject billPrinter = new JSONObject();
try {
billPrinter.put("appId", SystemConfig.p.getProperty("sf.partnerID"));//顾客编码
billPrinter.put("appKey", SystemConfig.p.getProperty("sf.checkWord"));//校验码
billPrinter.put("mailNo", waybillObj.getWaybillNo());//运单号
billPrinter.put("expressType", 1);//1-标准快递 2-顺丰标快(陆运)5-顺丰次晨 6-顺丰即日
billPrinter.put("payMethod", 1);//付款方式 1-寄付 2-到付 3-第三方付
billPrinter.put("orderNo", order.getNumber());//订单号
billPrinter.put("monthAccount", SystemConfig.p.getProperty("sf.monthlyCard"));
//寄件人信息
billPrinter.put("deliverCompany", "扬州诺康大药房有限公司");
billPrinter.put("deliverName", "吴赵龙");
billPrinter.put("deliverMobile", "15150808407");
billPrinter.put("deliverProvince", "江苏省");
billPrinter.put("deliverCity", "扬州市");
billPrinter.put("deliverCounty", "邗江区");
billPrinter.put("deliverAddress", "科技园路18号");
billPrinter.put("deliverShipperCode", "225000");
//收件人信息
billPrinter.put("consignerName", waybillObj.getContact());
billPrinter.put("consignerMobile", waybillObj.getMobile());
billPrinter.put("consignerProvince", waybillObj.getProvince());
billPrinter.put("consignerCity", waybillObj.getCity());
billPrinter.put("consignerCounty", waybillObj.getCounty());
billPrinter.put("consignerAddress", waybillObj.getAddress());
billPrinter.put("consignerShipperCode", "225000");
//billPrinter.put("totalFee", "");//费用合计
billPrinter.put("encryptMobile", true);//加密电话
billPrinter.put("encryptCustName", true);//加密收寄人信息
billPrinter.put("mainRemark", "");//主运单备注信息
//商品信息
JSONArray cargoInfoDtoList = new JSONArray();
for (OrderDetails ord: orderDetails) {
JSONObject cargoInfo = new JSONObject();
cargoInfo.put("cargo", ord.getProductName());
cargoInfo.put("cargoCount", ord.getDrugsNum());
cargoInfo.put("cargoUnit", "盒");
cargoInfo.put("remark", "医药物品,请小心轻放!");
cargoInfoDtoList.add(cargoInfo);
}
billPrinter.put("cargoInfoDtoList", cargoInfoDtoList);
String routeDes = waybillObj.getRouteDes();
JSONObject routeObj = JSONObject.parseObject(routeDes);
if (routeObj == null) {
return null;
}
billPrinter.put("zipCode", waybillObj.getOriginCode());
billPrinter.put("destCode", waybillObj.getDestCode());
billPrinter.put("insureValue", null);
//丰密信息
JSONArray rlsInfoDtoList = new JSONArray();
JSONObject rlsInfo = new JSONObject();
rlsInfo.put("waybillNo", routeObj.getString("waybillNo"));
rlsInfo.put("abFlag", StringUtils.isBlank(routeObj.getString("abFlag")) ? "" : routeObj.getString("abFlag"));
rlsInfo.put("xbFlag", StringUtils.isBlank(routeObj.getString("xbFlag")) ? "" : routeObj.getString("xbFlag"));
rlsInfo.put("proCode", StringUtils.isBlank(routeObj.getString("proCode")) ? "" : routeObj.getString("proCode"));
rlsInfo.put("destRouteLabel", StringUtils.isBlank(routeObj.getString("destRouteLabel")) ? "" : routeObj.getString("destRouteLabel"));
rlsInfo.put("destTeamCode", StringUtils.isBlank(routeObj.getString("destTeamCode")) ? "" : routeObj.getString("destTeamCode"));
rlsInfo.put("codingMapping", StringUtils.isBlank(routeObj.getString("codingMapping")) ? "" : routeObj.getString("codingMapping"));
rlsInfo.put("codingMappingOut", StringUtils.isBlank(routeObj.getString("codingMappingOut")) ? "" : routeObj.getString("codingMappingOut"));
rlsInfo.put("sourceTransferCode", StringUtils.isBlank(routeObj.getString("sourceTransferCode")) ? "" : routeObj.getString("sourceTransferCode"));
rlsInfo.put("printIcon", StringUtils.isBlank(routeObj.getString("printIcon")) ? "" : routeObj.getString("printIcon"));
rlsInfo.put("qrcode", StringUtils.isBlank(routeObj.getString("twoDimensionCode")) ? "" : routeObj.getString("twoDimensionCode"));
rlsInfoDtoList.add(rlsInfo);
billPrinter.put("rlsInfoDtoList", rlsInfoDtoList);
} catch (Exception e) {
log.error("丰桥API {下订单接口} Request Params Error = " + e.getMessage());
} finally {
log.info("顺丰面单打印实体初始化! id {} " + order.getNumber());
}
return billPrinter;
}
/**
* 下订单接口参数封装
* @param order
......@@ -86,7 +172,7 @@ public class ExpressOrderInfoUtils {
sender.put("tel", "0514-82360278");
sender.put("mobile", "15150808407");
sender.put("country", countryCode);
sender.put("province", "江苏");
sender.put("province", "江苏");
sender.put("city", "扬州市");
sender.put("county", "邗江区");
sender.put("address", "科技园路18号");
......@@ -170,7 +256,7 @@ public class ExpressOrderInfoUtils {
retObj.put("trackingType", 1);//1:根据顺丰运单号查询
JSONArray waybills = new JSONArray();
waybills.add("SF7444420632664");
//waybills.add("SF7444420632664");
retObj.put("trackingNumber", waybills);//顺丰运单号
retObj.put("methodType", 1);//标准路由查询
} catch (Exception e) {
......@@ -187,15 +273,15 @@ public class ExpressOrderInfoUtils {
public static String generateSfDigest(String msgData, Long timestamp, String checkWord) {
String msgDigest = null;
try {
// StringBuffer verifyText = new StringBuffer();
// verifyText.append(msgData);
// verifyText.append(timestamp);
// verifyText.append(checkWord);
StringBuffer verifyText = new StringBuffer();
verifyText.append(msgData);
verifyText.append(timestamp);
verifyText.append(checkWord);
String verifyText = msgData + timestamp + checkWord;
//String verifyText = msgData + timestamp + checkWord;
//因业务报文中可能包含加号、空格等特殊字符,需要urlEnCode处理
String text = URLEncoder.encode(verifyText, "UTF-8");
String text = URLEncoder.encode(verifyText.toString(), "UTF-8");
//进行Md5加密
MessageDigest md5 = MessageDigest.getInstance("MD5");
......
......@@ -34,4 +34,14 @@ public class FqConstants {
*/
public static final String SF_ORDER_ROUTE_URL = "https://sfapi-sbox.sf-express.com/std/service";
public static final String SF_ORDER_ROUTE_CODE = "EXP_RECE_SEARCH_ROUTES";
/**
* 2联150 丰密面单 调用打印机 不弹出窗口 适用于批量打印【二联单】
*/
public static final String TWO_UNITED_150 = "http://localhost:4040/sf/waybill/print?type=V2.0.FM_poster_100mm150mm&output=noAlertPrint";
/**
* 2联150 丰密面单 直接输出图片的BASE64编码字符串 可以使用html标签直接转换成图片【二联单】
*/
String TWO_UNITED_150_IMG = "http://localhost:4040/sf/waybill/print?type=V2.0.FM_poster_100mm150mm&output=image";
}
......@@ -180,13 +180,33 @@ public class WaybillController {
Sort sort = new Sort("t.create_time", OrderType.DESC);
List<Waybill> list = waybillService.fetchSearchByPage(conds, sort, 0, 0);
ExcelKit.$Export(Waybill.class, response).toExcel(list, "顺丰物流运单信息");
list.forEach(item -> {
if (StringUtils.equals(item.getFilterResult(), "1")) {
item.setFilterResult("人工确认");
} else if (StringUtils.equals(item.getFilterResult(), "2")) {
item.setFilterResult("可派收");
} else if (StringUtils.equals(item.getFilterResult(), "3")) {
item.setFilterResult("不可派收");
}
if (StringUtils.isNoneBlank(item.getContact()) && item.getContact().length() >=2) {
StringBuffer str = new StringBuffer(item.getContact());
str.replace(1, 2, "*");
item.setContact(str.toString());
}
if (StringUtils.isNoneBlank(item.getMobile())) {
StringBuffer str = new StringBuffer(item.getMobile());
str.replace(3, 7, "****");
item.setMobile(str.toString());
}
});
ExcelKit.$Export(Waybill.class, response).toExcel(list, "顺丰物流单信息");
}
@RequestMapping("/templateExcel")
@RequiresPermissions(value = WAYBILL_VIEW)
public void templateExcel(HttpServletRequest request, HttpServletResponse response) {
ExcelKit.$Export(Waybill.class, response).toExcel(null, "顺丰物流单信息");
ExcelKit.$Export(Waybill.class, response).toExcel(null, "顺丰物流单信息");
}
@RequestMapping("/importExcel")
......@@ -204,10 +224,10 @@ public class WaybillController {
}
String fileName = file.getOriginalFilename();
String filePath = uploadPath + File.separator + fileName;
File storeFile = new File(filePath);
File fileTmp = new File(filePath);
try {
file.transferTo(storeFile);
ExcelKit.$Import().setEmptyCellValue("").readExcel(storeFile, rowData -> {
file.transferTo(fileTmp);
ExcelKit.$Import().setEmptyCellValue("").readExcel(fileTmp, rowData -> {
if (!StringUtils.isEmpty(rowData.get(0))) {
Waybill waybill = new Waybill();
waybill.setAccountsId(accountId);
......@@ -228,8 +248,16 @@ public class WaybillController {
@RequestMapping("/orderSendOutForWaybill")
@ResponseBody
public JSONObject orderSendOutForWaybill(HttpServletRequest request, Long orderId) {
return waybillService.orderSendOutForWaybill(request, orderId);
}
/**
* 打印面单
* @return
*/
@RequestMapping("/orderPrinterBill")
@ResponseBody
public JSONObject orderPrinterBill(HttpServletRequest request, Long orderId) {
return waybillService.orderPrinterBill(request, orderId);
}
}
......@@ -42,13 +42,13 @@ LOG_URL=http://www.michang-tech.com.cn:6989/log/addlog
#\u6821\u9A8C\u5151\u6362\u5BC6\u7801KEY
MEMBER_PASSWORD_KEY=DONGCHANGINT9527;
list.refreshtoken=true
jwt.domain=pd.shxrtech.com
jwt.domain=localhost
#\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD
jwt.duration=86400000
#\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u03AAtrue
security.secure=false
#\u662F\u5426\u96C6\u7FA4 master\u4E3Atrue
quartz.isCluster=true
quartz.isCluster=false
#\u987A\u4E30API\u914D\u7F6E\u53C2\u6570
#\u987A\u4E30\u5BA2\u6237\u7F16\u7801
......
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 to comment