Commit 92b31cb9 authored by 张永's avatar 张永

增加网商回调

parent 163ca59f
......@@ -87,7 +87,7 @@ public class PayNotifyController {
@ApiOperation("网商银行回调通知接口")
@RequestMapping(value = "/mybankCallback", method = RequestMethod.POST)
public Object mybankCallback(@RequestBody String req, HttpServletResponse resp) {
logger.info("网商银行回调通知接口 {}",req);
logger.info("从egoPay中接收网商银行回调通知接口 {}",req);
return "success";
}
......
......@@ -49,4 +49,6 @@ public interface OrderService {
public List<Map<String, Object>> payCallback(WxPayResponse postData);
public List<Map<String, Object>> mePayCallback(String req);
public List<Map<String, Object>> meBankCallback(String req);
}
......@@ -859,6 +859,8 @@ public class CartQueryServiceImpl implements CartQueryService {
+ " from tYWPromoMain a, tYWPromoDtl b "
+ " where a.sPromoPaperNO = b.sPromoPaperNO "
+ " and a.sPromoPaperNORuleID = b.sPromoPaperNO + isnull(convert(varchar,b.nRuleID),'') "
+ " and a.nTag&1=0 "
+ " and b.nTag&1=0 "
+ " ) p on p.sPromoPaperNO = c.sPromoPaperNO and p.nGoodsID = c.nGoodsID "
+ "WHERE c.sShopNO = '" + shopNo + "'";
String sqlClearPromoNo =
......
......@@ -21,7 +21,7 @@ import org.springframework.jdbc.UncategorizedSQLException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.egolm.common.DateUtil;
import com.egolm.common.StringUtil;
import com.egolm.common.Util;
......@@ -39,77 +39,82 @@ import com.egolm.shop.bean.WxPayResponse;
import com.egolm.shop.common.XException;
import com.egolm.shop.common.utils.I18NUtils;
import com.qcloud.cos.utils.DateUtils;
@Service
public class OrderServiceImpl implements OrderService {
protected final Logger logger = LoggerFactory.getLogger(OrderServiceImpl.class);
@Autowired
private JdbcTemplate jdbcTemplate;
/* @Autowired
QiyeWxService wxService;
*/
/*
* @Autowired QiyeWxService wxService;
*/
/**
* 订单检查
* <p>Title: orderCheck</p>
* <p>Description: </p>
* <p>
* Title: orderCheck
* </p>
* <p>
* Description:
* </p>
*
* @param params
* @return
* @return
* @see com.egolm.shop.api.service.oms.service.OrderService#orderCheck(java.util.Map)
*/
public String orderCheck(Map<String,Object> params) {
public String orderCheck(Map<String, Object> params) {
jdbcTemplate.setDialect(new SqlServerDialect());
String LangID = params.get("langID")+"";
String LangID = params.get("langID") + "";
try {
Rjx rjx;
String shopNO = params.get("shopNO")+"";
String terminal = params.get("terminal")+"";
String sql="exec up_NewCreateCartTempItem '"+shopNO+"','"+terminal+"' ";
List<Map<String ,Object>> resultMap=jdbcTemplate.executeMutil(sql).getDatas().get(0);
if (Util.objTo(resultMap.get(0).get("Status"), Integer.class) == 0 && Util.objTo(resultMap.get(resultMap.size()-1).get("Status"), Integer.class) == 0) {
String shopNO = params.get("shopNO") + "";
String terminal = params.get("terminal") + "";
String sql = "exec up_NewCreateCartTempItem '" + shopNO + "','" + terminal + "' ";
List<Map<String, Object>> resultMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
if (Util.objTo(resultMap.get(0).get("Status"), Integer.class) == 0
&& Util.objTo(resultMap.get(resultMap.size() - 1).get("Status"), Integer.class) == 0) {
rjx = Rjx.jsonOk();
rjx.setData(resultMap);
} else {
Map<String, Object> lastest = resultMap.get(resultMap.size() - 1);
rjx = Rjx.jsonErr().setMessage((String)lastest.get("ErrorMsg")).setData(resultMap);
}
rjx = Rjx.jsonErr().setMessage((String) lastest.get("ErrorMsg")).setData(resultMap);
}
return rjx.toJson();
} catch(UncategorizedSQLException se) {
} catch (UncategorizedSQLException se) {
String errorFullMsg = se.getMessage();
String key = "com.microsoft.sqlserver.jdbc.SQLServerException:";
String errorSubMsg = errorFullMsg.substring(errorFullMsg.lastIndexOf(key)+key.length(), errorFullMsg.length());
String errorSubMsg = errorFullMsg.substring(errorFullMsg.lastIndexOf(key) + key.length(),
errorFullMsg.length());
System.out.println(errorFullMsg);
System.out.println(errorSubMsg);
return Rjx.jsonErr().setMessage(I18NUtils.getMessage(LangID, "Msg_Submit_Goods_error")).set("result", errorSubMsg).toJson();
}catch (Exception e) {
System.out.println("e...."+e.getMessage());
return Rjx.jsonErr().setMessage(I18NUtils.getMessage(LangID, "Msg_Submit_Goods_error"))
.set("result", errorSubMsg).toJson();
} catch (Exception e) {
System.out.println("e...." + e.getMessage());
e.printStackTrace();
return Rjx.jsonErr().setMessage(I18NUtils.getMessage(LangID, "Msg_Submit_Goods_failure")).toJson();
}
}
}
/**
*
* @Title: submit
* @Description: 提交订单
* @param: @param submitObj
* @param: @return
* @return: String
* @throws
* @Title: submit @Description: 提交订单 @param: @param
* submitObj @param: @return @return: String @throws
*/
public String submit(JSONObject submitObj) {
jdbcTemplate.setDialect(new SqlServerDialect());
String LangID=""+submitObj.get("langID");
public String submit(JSONObject submitObj) {
jdbcTemplate.setDialect(new SqlServerDialect());
String LangID = "" + submitObj.get("langID");
try {
String shopNO=""+submitObj.get("shopNO");
String payID=""+submitObj.get("payTypeID");
String terminalTypeID=""+submitObj.get("terminal");
String addrID=""+submitObj.get("addrID");
String orderMemo=""+submitObj.get("orderMemo");
String couponNO=""+submitObj.get("couponNO");
String couponTypeID=""+submitObj.get("couponTypeID");
String shopNO = "" + submitObj.get("shopNO");
String payID = "" + submitObj.get("payTypeID");
String terminalTypeID = "" + submitObj.get("terminal");
String addrID = "" + submitObj.get("addrID");
String orderMemo = "" + submitObj.get("orderMemo");
String couponNO = "" + submitObj.get("couponNO");
String couponTypeID = "" + submitObj.get("couponTypeID");
String formId = submitObj.getString("formId");
String bankType = submitObj.getString("bankType");
String bankAccount = submitObj.getString("bankAccount");
......@@ -123,125 +128,139 @@ public class OrderServiceImpl implements OrderService {
revBankType = StringUtil.isBlank(revBankType) ? "" : revBankType;
revBankAccount = StringUtil.isBlank(revBankAccount) ? "" : revBankAccount;
revBankAccountNo = StringUtil.isBlank(revBankAccountNo) ? "" : revBankAccountNo;
String sql = "exec up_NewCreatetSalesOrder '" + shopNO + "',null, '" + payID + "', '" + terminalTypeID + "', '" + addrID + "', '" + orderMemo + "', '" + couponNO + "','" + couponTypeID + "', '', '1', '" + (bankType == null ? "" : bankType) + "', '" + (bankAccount == null ? "" : bankAccount) + "', '" + bankAccountName + "', '" + revBankType + "', '" + revBankAccount + "', '" + revBankAccountNo + "'";
String sql = "exec up_NewCreatetSalesOrder '" + shopNO + "',null, '" + payID + "', '" + terminalTypeID
+ "', '" + addrID + "', '" + orderMemo + "', '" + couponNO + "','" + couponTypeID + "', '', '1', '"
+ (bankType == null ? "" : bankType) + "', '" + (bankAccount == null ? "" : bankAccount) + "', '"
+ bankAccountName + "', '" + revBankType + "', '" + revBankAccount + "', '" + revBankAccountNo
+ "'";
List<Map<String, Object>> commitMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
if (commitMap != null && commitMap.size() > 0 && commitMap.get(0) != null && Util.objTo(commitMap.get(0).get("Status"), Integer.class) == 0 && Util.objTo(commitMap.get(commitMap.size()-1).get("Status"), Integer.class) == 0) {
String sSalesOrderID = (String)commitMap.get(0).get("SalesOrderID");
jdbcTemplate.update("update tSalesOrder set sFormID = ?, sEmail = ?, sSalesmanNO = ? where sSalesOrderID = ?", formId, email, salesmanNo, sSalesOrderID);
//this.sendWxMessage(sSalesOrderID);
return Rjx.jsonOk().setData(commitMap).toJson();
if (commitMap != null && commitMap.size() > 0 && commitMap.get(0) != null
&& Util.objTo(commitMap.get(0).get("Status"), Integer.class) == 0
&& Util.objTo(commitMap.get(commitMap.size() - 1).get("Status"), Integer.class) == 0) {
String sSalesOrderID = (String) commitMap.get(0).get("SalesOrderID");
jdbcTemplate.update(
"update tSalesOrder set sFormID = ?, sEmail = ?, sSalesmanNO = ? where sSalesOrderID = ?",
formId, email, salesmanNo, sSalesOrderID);
// this.sendWxMessage(sSalesOrderID);
return Rjx.jsonOk().setData(commitMap).toJson();
} else {
String errorMsg = "";
if(commitMap.size()>1){
errorMsg = (String)commitMap.get(0).get("StatusName")+";"+(String)commitMap.get(1).get("StatusName");
}else{
errorMsg = (String)commitMap.get(0).get("StatusName");
if (commitMap.size() > 1) {
errorMsg = (String) commitMap.get(0).get("StatusName") + ";"
+ (String) commitMap.get(1).get("StatusName");
} else {
errorMsg = (String) commitMap.get(0).get("StatusName");
}
return Rjx.jsonErr().setMessage(errorMsg).set("errorMsg", errorMsg).setData(commitMap).toJson();
}
} catch (Exception e) {
e.printStackTrace();
return Rjx.jsonErr().set("errorMsg", e.getMessage()).setMessage(I18NUtils.getMessage(LangID, "Msg_Submit_Order_error")).toJson();
return Rjx.jsonErr().set("errorMsg", e.getMessage())
.setMessage(I18NUtils.getMessage(LangID, "Msg_Submit_Order_error")).toJson();
}
}
@Override
public String queryOrderList(String orgNo, String shopNo, Integer status, String[] orderType, String langID, Page page) {
if(status == null) {
public String queryOrderList(String orgNo, String shopNo, Integer status, String[] orderType, String langID,
Page page) {
if (status == null) {
status = 0;
}
//订单状态 0.全部 1. 待付款 2.待审核 3.待发货 4.已发货 5.已完成 6.已取消 7待补款
String sql = "select distinct a.* from tSalesOrder a left join tSalesOrderSub b on a.sSalesOrderID = b.sSalesOrderID where a.sShopNO = '" + shopNo + "' and a.sOrgNO = '" + orgNo + "'";
if(status == 0) {
// 订单状态 0.全部 1. 待付款 2.待审核 3.待发货 4.已发货 5.已完成 6.已取消 7待补款
String sql = "select distinct a.* from tSalesOrder a left join tSalesOrderSub b on a.sSalesOrderID = b.sSalesOrderID where a.sShopNO = '"
+ shopNo + "' and a.sOrgNO = '" + orgNo + "'";
if (status == 0) {
sql += "";
} else if(status == 1) {
} else if (status == 1) {
sql += " and a.sSalesOrderPayTypeID = '4' and a.nOrderStatus = 0";
} else if(status == 2) {
} else if (status == 2) {
sql += " and ((a.sSalesOrderPayTypeID = '2' and a.nOrderStatus = 0) or (a.sSalesOrderPayTypeID = '4' and a.nOrderStatus&37 = 32))";
} else if(status == 3) {
} else if (status == 3) {
sql += " and a.nOrderStatus&29 = 4 and a.nOrderStatus&128=0 ";
} else if(status == 4) {
} else if (status == 4) {
sql += " and a.nOrderStatus&129 = 128 and a.nOrderStatus&16=0 ";
} else if(status == 5) {
sql += " and a.nOrderStatus&17 = 16";
} else if(status == 6) {
} else if (status == 5) {
sql += " and a.nOrderStatus&17 = 16";
} else if (status == 6) {
sql += " and a.nOrderStatus&1 = 1";
} else if(status == 7) {
} else if (status == 7) {
sql += " and b.sSalesOrderTypeID = '0' and b.nDebtAmount > 0 ";
}else {
} else {
throw new XException("订单状态不存在");
}
if(orderType != null && orderType.length > 0) {
if (orderType != null && orderType.length > 0) {
sql += " and a.sB2BOrderTypeID in (" + StringUtil.join("', '", "'", "'", "", orderType) + ")";
}
List<Map<String, Object>> orderList = jdbcTemplate.limit(sql, page);
if(orderList.size() > 0) {
List<String> orderIds = orderList.stream().map(o-> (String)o.get("sSalesOrderID")).collect(Collectors.toList());
String sql2 = "select sod.*,PromoSalePrice=CONVERT(NUMERIC(12,2),case when sod.nSaleQty = 0 then 0 else ROUND((sod.nSaleAmount)/sod.nSaleQty,2) end),OriginaSaleAmount=sod.nSaleAmount+sod.nDisAmount,ISGift = sod.nTag&1,agp.sURL "
+ " from tSalesOrderDtl sod left join V_GetminAgentGoodsPic agp on agp.nAgentID = sod.nAgentID and agp.nGoodsID = sod.nGoodsID and agp.sPicTypeID = 1 "
+ " where sod.sSalesOrderID in (" + StringUtil.join("', '", "'", "'", orderIds) + ")";
if (orderList.size() > 0) {
List<String> orderIds = orderList.stream().map(o -> (String) o.get("sSalesOrderID"))
.collect(Collectors.toList());
String sql2 = "select sod.*,PromoSalePrice=CONVERT(NUMERIC(12,2),case when sod.nSaleQty = 0 then 0 else ROUND((sod.nSaleAmount)/sod.nSaleQty,2) end),OriginaSaleAmount=sod.nSaleAmount+sod.nDisAmount,ISGift = sod.nTag&1,agp.sURL "
+ " from tSalesOrderDtl sod left join V_GetminAgentGoodsPic agp on agp.nAgentID = sod.nAgentID and agp.nGoodsID = sod.nGoodsID and agp.sPicTypeID = 1 "
+ " where sod.sSalesOrderID in (" + StringUtil.join("', '", "'", "'", orderIds) + ")";
List<Map<String, Object>> orderDtlList = jdbcTemplate.queryForList(sql2);
Map<String, List<Map<String, Object>>> dtlML = Util.listToML(orderDtlList, "sSalesOrderID");
for(Map<String, Object> orderMap : orderList) {
String sSalesOrderID = (String)orderMap.get("sSalesOrderID");
for (Map<String, Object> orderMap : orderList) {
String sSalesOrderID = (String) orderMap.get("sSalesOrderID");
List<Map<String, Object>> dtlList = dtlML.get(sSalesOrderID);
orderMap.put("list", dtlList);
}
String sql3 = "select * from tSalesOrderSub where sSalesOrderID in (" + StringUtil.join("', '", "'", "'", orderIds) + ")";
String sql3 = "select * from tSalesOrderSub where sSalesOrderID in ("
+ StringUtil.join("', '", "'", "'", orderIds) + ")";
List<Map<String, Object>> subList = jdbcTemplate.queryForList(sql3);
if(subList.size() > 0) {
List<String> subIds = subList.stream().map(o-> (String)o.get("sSubOrderID")).collect(Collectors.toList());
String sql4 = "select sosd.*,PromoSalePrice=CONVERT(NUMERIC(12,2),case when sosd.nSaleQty = 0 then 0 else ROUND((sosd.nSaleAmount)/sosd.nSaleQty,2) end),OriginaSaleAmount=sosd.nSaleAmount+sosd.nDisAmount,ISGift = sosd.nTag&1,"
+ " agp.sURL from tSalesOrderSubDtl sosd left join V_GetminAgentGoodsPic agp on agp.nAgentID = sosd.nAgentID and agp.nGoodsID = sosd.nGoodsID and agp.sPicTypeID = 1"
+ " where sosd.sSubOrderID in (" + StringUtil.join("', '", "'", "'", subIds) + ")";
if (subList.size() > 0) {
List<String> subIds = subList.stream().map(o -> (String) o.get("sSubOrderID"))
.collect(Collectors.toList());
String sql4 = "select sosd.*,PromoSalePrice=CONVERT(NUMERIC(12,2),case when sosd.nSaleQty = 0 then 0 else ROUND((sosd.nSaleAmount)/sosd.nSaleQty,2) end),OriginaSaleAmount=sosd.nSaleAmount+sosd.nDisAmount,ISGift = sosd.nTag&1,"
+ " agp.sURL from tSalesOrderSubDtl sosd left join V_GetminAgentGoodsPic agp on agp.nAgentID = sosd.nAgentID and agp.nGoodsID = sosd.nGoodsID and agp.sPicTypeID = 1"
+ " where sosd.sSubOrderID in (" + StringUtil.join("', '", "'", "'", subIds) + ")";
List<Map<String, Object>> subDtlList = jdbcTemplate.queryForList(sql4);
Map<String, List<Map<String, Object>>> subDtlML = Util.listToML(subDtlList, "sSubOrderID");
for(Map<String, Object> subMap : subList) {
String sSubOrderID = (String)subMap.get("sSubOrderID");
for (Map<String, Object> subMap : subList) {
String sSubOrderID = (String) subMap.get("sSubOrderID");
List<Map<String, Object>> dtlList = subDtlML.get(sSubOrderID);
subMap.put("list", dtlList);
}
}
Map<String, List<Map<String, Object>>> ml = Util.listToML(subList, "sSalesOrderID");
for(Map<String, Object> orderMap : orderList) {
String sSalesOrderID = (String)orderMap.get("sSalesOrderID");
for (Map<String, Object> orderMap : orderList) {
String sSalesOrderID = (String) orderMap.get("sSalesOrderID");
List<Map<String, Object>> subListItem = ml.get(sSalesOrderID);
orderMap.put("subList", subListItem == null ? new Object[0] : subListItem);
}
}
return Rjx.jsonOk().set("list", orderList).toJson();
}
@Override
public String getOrderDetail(String salesOrderId) {
Map<String, Object> orderMap = null;
try {
orderMap =jdbcTemplate.queryForMap("select * from tSalesOrder where sSalesOrderID = ?", salesOrderId);
orderMap = jdbcTemplate.queryForMap("select * from tSalesOrder where sSalesOrderID = ?", salesOrderId);
} catch (EmptyResultDataAccessException e) {
throw new XException("订单编号错误或订单不存在");
}
List<Map<String, Object>> orderDtlList = new ArrayList<Map<String, Object>>();
if(orderMap.size() > 0) {
if (orderMap.size() > 0) {
String sql2 = "select sod.*,sos.nSendQty, PromoSalePrice=CONVERT(NUMERIC(12,2),ROUND((sod.nSaleAmount)/sod.nSaleQty,2)),OriginaSaleAmount=sod.nSaleAmount+sod.nDisAmount,ISGift = sod.nTag&1,"
+ " agp.sURL, pm.sPromoName, pm.sPromoTheme, pm.sPromoActionType sPromoType, pm.sPromoActionTypeID sPromoTypeID "
+ " from tSalesOrderDtl sod left join (select a.sPromoPaperNO, a.sPromoName, a.sPromoTheme, a.sPromoActionTypeID, a.sPromoActionType, b.nGoodsID "
+ " from tYWPromoMain a, tYWPromoDtl b "
+ " where a.sPromoPaperNO = b.sPromoPaperNO "
+ " and a.sPromoPaperNORuleID = b.sPromoPaperNO + isnull(convert(varchar,b.nRuleID),'') "
+ " ) pm on pm.sPromoPaperNO = sod.sPromoPaperNO and pm.nGoodsID = sod.nGoodsID "
+ " left join V_GetminAgentGoodsPic agp on agp.nAgentID = sod.nAgentID and agp.nGoodsID = sod.nGoodsID and agp.sPicTypeID = 1"
+ " left join tSalesOrderSubDtl sos on sos.sSalesOrderID = sod.sSalesOrderID and sos.nGoodsID = sod.nGoodsID "
+ " where sod.sSalesOrderID = ?";
+ " agp.sURL, pm.sPromoName, pm.sPromoTheme, pm.sPromoActionType sPromoType, pm.sPromoActionTypeID sPromoTypeID "
+ " from tSalesOrderDtl sod left join (select a.sPromoPaperNO, a.sPromoName, a.sPromoTheme, a.sPromoActionTypeID, a.sPromoActionType, b.nGoodsID "
+ " from tYWPromoMain a, tYWPromoDtl b "
+ " where a.sPromoPaperNO = b.sPromoPaperNO "
+ " and a.sPromoPaperNORuleID = b.sPromoPaperNO + isnull(convert(varchar,b.nRuleID),'') "
+ " and a.nTag&1=0 "
+ " and b.nTag&1=0 "
+ " ) pm on pm.sPromoPaperNO = sod.sPromoPaperNO and pm.nGoodsID = sod.nGoodsID "
+ " left join V_GetminAgentGoodsPic agp on agp.nAgentID = sod.nAgentID and agp.nGoodsID = sod.nGoodsID and agp.sPicTypeID = 1"
+ " left join tSalesOrderSubDtl sos on sos.sSalesOrderID = sod.sSalesOrderID and sos.nGoodsID = sod.nGoodsID "
+ " where sod.sSalesOrderID = ?";
orderDtlList = jdbcTemplate.queryForList(sql2, salesOrderId);
}
String sqlPay = ""
+ "select "
+ "sum(case when sPayTypeID = '1' then nPayAmount else 0 end) nCashPayAmount, "
String sqlPay = "" + "select " + "sum(case when sPayTypeID = '1' then nPayAmount else 0 end) nCashPayAmount, "
+ "sum(case when sPayTypeID = 'WxPay' then nPayAmount else 0 end) nWxPayAmount, "
+ "sum(case when sPayTypeID = 'Coupon' then nPayAmount else 0 end) nCouponPayAmount, "
+ "sum(nPayAmount) nTotalPayAmount "
+ "from tSalesOrderPay where sSalesOrderID = ?";
+ "sum(nPayAmount) nTotalPayAmount " + "from tSalesOrderPay where sSalesOrderID = ?";
Map<String, Object> payMap = jdbcTemplate.queryForMap(sqlPay, salesOrderId);
payMap.put("nOrderTotalAmount", orderMap.get("nTotalSaleAmount"));
return Rjx.jsonOk().set("payData", payMap).set("list", orderMap).set("detail", orderDtlList).toJson();
......@@ -249,109 +268,64 @@ public class OrderServiceImpl implements OrderService {
@Override
public String queryOrderDetailList(String salesOrderId) {
String sql = "select " +
" sSubOrderID, " +
" sSalesOrderID, " +
" sAgentContractNO, " +
" sWarehouseNO, " +
" nAgentID, " +
" sOrgNO, " +
" sCustNO, " +
" sShopNO, " +
" sSalesOrderTypeID, " +
" sSalesOrderType, " +
" nTotalSaleQty, " +
" nTotalSaleAmount, " +
" nTotalDisAmount, " +
" sContacts, " +
" sMobile, " +
" sTel, " +
" sAddress, " +
" sPostalcode, " +
" sEmail, " +
" sOrderMemo, " +
" dOrderDate, " +
" dSendDate, " +
" nTotalSendQty, " +
" nTotalSendAmount, " +
" dReceiveDate, " +
" nTotalReceiveQty, " +
" nTotalReceiveAmount, " +
" sDriverNO, " +
" sDriverName, " +
" nOrderStatus, " +
" nOrderStatusName, " +
" dUpdate, " +
" nTag, " +
" dLastUpdateTime, " +
" dPayDate, " +
" sPayUser, " +
" sSendUser, " +
" nTotalPayAmount, " +
" nTotalPayDisAmount, " +
" nHastenNum, " +
" dLastHastenTime, " +
" sSalesmanNO, " +
" dSettleDate, " +
" sOldSubOrderID, " +
" sCreateUser, " +
" dCreateDate, " +
" sConfirmUser, " +
" dConfirmDate, " +
" sSendPaperNO, " +
" nRealPayDisAmount, " +
" sWareTrainNO, " +
" sWareTrainPaperNO, " +
" sInvoiceNO, " +
" nExpressFee, " +
" sDeliveryTypeID, " +
" sDeliveryType, " +
" sBankAccount, " +
" sBankType, " +
" sB2BOrderTypeID, " +
" sB2BOrderType, " +
" nOldTotalSaleAmount, " +
" nOldTotalSaleQty, " +
" sBankAccountName, " +
" sRevBankType, " +
" sRevBankAccountNO, " +
" sRevBankAccount, " +
" sBindPaperNO, " +
" dBindDate, " +
" dCancelTime, " +
" sCancelRemark, " +
" sCancelUser, " +
" sSettleNO, " +
" nDebtAmount, " +
" dExpectDate = convert(varchar(10), dExpectDate, 120)" +
" from tSalesOrderSub where sSalesOrderID = ?";
String sql = "select " + " sSubOrderID, " + " sSalesOrderID, " + " sAgentContractNO, "
+ " sWarehouseNO, " + " nAgentID, " + " sOrgNO, " + " sCustNO, "
+ " sShopNO, " + " sSalesOrderTypeID, " + " sSalesOrderType, "
+ " nTotalSaleQty, " + " nTotalSaleAmount, " + " nTotalDisAmount, "
+ " sContacts, " + " sMobile, " + " sTel, " + " sAddress, "
+ " sPostalcode, " + " sEmail, " + " sOrderMemo, " + " dOrderDate, "
+ " dSendDate, " + " nTotalSendQty, " + " nTotalSendAmount, "
+ " dReceiveDate, " + " nTotalReceiveQty, " + " nTotalReceiveAmount, "
+ " sDriverNO, " + " sDriverName, " + " nOrderStatus, " + " nOrderStatusName, "
+ " dUpdate, " + " nTag, " + " dLastUpdateTime, " + " dPayDate, "
+ " sPayUser, " + " sSendUser, " + " nTotalPayAmount, "
+ " nTotalPayDisAmount, " + " nHastenNum, " + " dLastHastenTime, "
+ " sSalesmanNO, " + " dSettleDate, " + " sOldSubOrderID, " + " sCreateUser, "
+ " dCreateDate, " + " sConfirmUser, " + " dConfirmDate, " + " sSendPaperNO, "
+ " nRealPayDisAmount, " + " sWareTrainNO, " + " sWareTrainPaperNO, "
+ " sInvoiceNO, " + " nExpressFee, " + " sDeliveryTypeID, " + " sDeliveryType, "
+ " sBankAccount, " + " sBankType, " + " sB2BOrderTypeID, " + " sB2BOrderType, "
+ " nOldTotalSaleAmount, " + " nOldTotalSaleQty, " + " sBankAccountName, "
+ " sRevBankType, " + " sRevBankAccountNO, " + " sRevBankAccount, "
+ " sBindPaperNO, " + " dBindDate, " + " dCancelTime, " + " sCancelRemark, "
+ " sCancelUser, " + " sSettleNO, " + " nDebtAmount, "
+ " dExpectDate = convert(varchar(10), dExpectDate, 120)"
+ " from tSalesOrderSub where sSalesOrderID = ?";
List<Map<String, Object>> subList = jdbcTemplate.queryForList(sql, salesOrderId);
if(subList.size() > 0) {
List<String> subIds = subList.stream().map(o-> (String)o.get("sSubOrderID")).collect(Collectors.toList());
String sql2 = "select sosd.*,PromoSalePrice=CONVERT(NUMERIC(12,2),ROUND((sosd.nSaleAmount)/sosd.nSaleQty,2)),OriginaSaleAmount=sosd.nSaleAmount+sosd.nDisAmount,ISGift = sosd.nTag&1,"
+ " agp.sURL, pm.sPromoTheme, pm.sPromoActionType sPromoType, pm.sPromoActionTypeID sPromoTypeID "
+ " from tSalesOrderSubDtl sosd left join tYWPromoMain pm on pm.sPromoPaperNO = sosd.sPromoPaperNO left join V_GetminAgentGoodsPic agp on agp.nAgentID = sosd.nAgentID and agp.nGoodsID = sosd.nGoodsID and agp.sPicTypeID = 1"
+ " where sosd.sSubOrderID in (" + StringUtil.join("', '", "'", "'", subIds) + ")";
if (subList.size() > 0) {
List<String> subIds = subList.stream().map(o -> (String) o.get("sSubOrderID")).collect(Collectors.toList());
String sql2 = "select sosd.*, PromoSalePrice=CONVERT(NUMERIC(12,2),ROUND((sosd.nSaleAmount)/sosd.nSaleQty,2)), "
+ " OriginaSaleAmount=sosd.nSaleAmount+sosd.nDisAmount,ISGift = sosd.nTag&1,"
+ " agp.sURL, pm.sPromoTheme, pm.sPromoActionType sPromoType, pm.sPromoActionTypeID sPromoTypeID "
+ " from tSalesOrderSubDtl sosd left join (select a.sPromoPaperNO, a.sPromoName, a.sPromoTheme, a.sPromoActionTypeID, a.sPromoActionType, b.nGoodsID "
+ " from tYWPromoMain a, tYWPromoDtl b "
+ " where a.sPromoPaperNO = b.sPromoPaperNO "
+ " and a.sPromoPaperNORuleID = b.sPromoPaperNO + isnull(convert(varchar,b.nRuleID),'') "
+ " and a.nTag&1=0 "
+ " and b.nTag&1=0"
+ " ) pm on pm.sPromoPaperNO = sosd.sPromoPaperNO and pm.nGoodsID = sosd.nGoodsID"
+ " left join V_GetminAgentGoodsPic agp on agp.nAgentID = sosd.nAgentID and agp.nGoodsID = sosd.nGoodsID and agp.sPicTypeID = 1"
+ " where sosd.sSubOrderID in (" + StringUtil.join("', '", "'", "'", subIds) + ")";
List<Map<String, Object>> subDtlList = jdbcTemplate.queryForList(sql2);
Map<String, List<Map<String, Object>>> subDtlML = Util.listToML(subDtlList, "sSalesOrderID");
for(Map<String, Object> subMap : subList) {
String sSubOrderID = (String)subMap.get("sSubOrderID");
for (Map<String, Object> subMap : subList) {
String sSubOrderID = (String) subMap.get("sSubOrderID");
List<Map<String, Object>> dtlList = subDtlML.get(sSubOrderID);
subMap.put("list", dtlList);
}
}
return Rjx.jsonOk().set("list", subList).toJson();
}
@Transactional
public List<Map<String, Object>> paySuccess(String sSalesOrderID, BigDecimal nPayAmount, String sOpenID, String sTransTraceNO, String sOutTradeNO, Date dPayDateTime) {
public List<Map<String, Object>> paySuccess(String sSalesOrderID, BigDecimal nPayAmount, String sOpenID,
String sTransTraceNO, String sOutTradeNO, Date dPayDateTime) {
List<Map<String, Object>> returnMap = new ArrayList<Map<String, Object>>();
Integer nIdx = jdbcTemplate.queryForInt("select ISNULL(MAX(nIdx),0) from tSalesOrderPay where sSalesOrderID = ?", sSalesOrderID);
Integer nIdx = jdbcTemplate
.queryForInt("select ISNULL(MAX(nIdx),0) from tSalesOrderPay where sSalesOrderID = ?", sSalesOrderID);
nPayAmount = nPayAmount.multiply(new BigDecimal(0.01)).setScale(2, BigDecimal.ROUND_HALF_UP);
Map<String, Object> map = new HashMap<String, Object>();
map.put("sSalesOrderID", sSalesOrderID);
map.put("nIdx", ++nIdx);
......@@ -367,17 +341,20 @@ public class OrderServiceImpl implements OrderService {
map.put("dLastUpdateTime", new Date());
Dialect dialect = jdbcTemplate.getDialect();
Sql sqlDesc = dialect.argsInsert("tSalesOrderPay", map);
String sql = "if not exists (select * from tSalesOrderPay where sTransTraceNO = '" + sTransTraceNO + "') " + sqlDesc.getSql();
String sql = "if not exists (select * from tSalesOrderPay where sTransTraceNO = '" + sTransTraceNO + "') "
+ sqlDesc.getSql();
jdbcTemplate.update(sql, sqlDesc.getArgs());
jdbcTemplate.update("update tSalesOrder set nOrderStatus = nOrderStatus|32 where sSalesOrderID = ?", sSalesOrderID);
jdbcTemplate.update("update tSalesOrder set nOrderStatus = nOrderStatus|32 where sSalesOrderID = ?",
sSalesOrderID);
try {
returnMap = jdbcTemplate.executeMutil("exec Up_Ego_SplitOrderPrd '" + sSalesOrderID + "'").getDatas().get(0);
} catch (Exception e) {
e.printStackTrace();
returnMap = jdbcTemplate.executeMutil("exec Up_Ego_SplitOrderPrd '" + sSalesOrderID + "'").getDatas()
.get(0);
} catch (Exception e) {
e.printStackTrace();
}
return returnMap;
}
@Override
public String getSubOrderDetail(String subOrderID) {
new ArrayList<Map<String, Object>>();
......@@ -386,58 +363,57 @@ public class OrderServiceImpl implements OrderService {
String msql = "select convert(int, sValue1) FROM tSystemCtrl WHERE sCode = 'SaleReturnDays' ";
ReturnDay = jdbcTemplate.queryForInt(msql);
} catch (Exception e) {
}
Map<String, Object> subOrderMap = jdbcTemplate.queryForMap(""
+ "select "
+ "sos.*, "
Map<String, Object> subOrderMap = jdbcTemplate.queryForMap("" + "select " + "sos.*, "
+ " IsRefund = case when isnull(sos.sBindPaperNO,'') = '' then 1 when sos.nOrderStatus&17=0 then 0 when datediff(dd,dateadd(dd,1,convert(date,sos.dReceiveDate)),getdate()) >= ? then 0 else 1 end, "
+ " LeftReturnQty = isnull(d.nSendQty,0) - isnull(d.nReturnQty,0), "
+ "case when sos.nOrderStatus&145 = 144 then '16' when sos.nOrderStatus&145 = 128 then '8' when sos.nOrderStatus&145 = 0 then '4' when sos.nOrderStatus&5 = 4 then '2' else '0' end nOrderStatus, "
+ "case when sos.nOrderStatus&145 = 144 then '已完成' when sos.nOrderStatus&145 = 128 then '配送中' when sos.nOrderStatus&145 = 0 then '待发货' when sos.nOrderStatus&5 = 4 then '已审核' else '未审核' end sOrderStatusText "
+ "from tSalesOrderSub sos left join (select sSubOrderID, nSendQty = sum(nSendQty), nReturnQty = sum(nReturnQty) from tSalesOrderSubDtl where sSubOrderID = ? group by sSubOrderID) d on sos.sSubOrderID = d.sSubOrderID "
+ " where sos.sSubOrderID = ?", ReturnDay,subOrderID,subOrderID);
Map<String, Object> orderMap = jdbcTemplate.queryForMap(""
+ "select "
+ "so.*, "
+ " where sos.sSubOrderID = ?", ReturnDay, subOrderID, subOrderID);
Map<String, Object> orderMap = jdbcTemplate.queryForMap("" + "select " + "so.*, "
+ "case when so.nOrderStatus&145 = 144 then '16' when so.nOrderStatus&145 = 128 then '8' when so.nOrderStatus&145 = 0 then '4' when so.nOrderStatus&5 = 4 then '2' else '0' end nOrderStatus, "
+ "case when so.nOrderStatus&145 = 144 then '已完成' when so.nOrderStatus&145 = 128 then '配送中' when so.nOrderStatus&145 = 0 then '待发货' when so.nOrderStatus&5 = 4 then '已审核' else '未审核' end sOrderStatusText "
+ "from tSalesOrder so where so.sSalesOrderID = ?", subOrderMap.get("sSalesOrderID"));
String sql = ""
+ "select "
+ "sosd.*, PromoSalePrice=CONVERT(NUMERIC(12,2),ROUND((sosd.nSaleAmount)/sosd.nSaleQty,2)),OriginaSaleAmount=sosd.nSaleAmount+sosd.nDisAmount,ISGift = sosd.nTag&1, "
+ "sosd.nSendQty - isnull(sosd.nReturnQty,0) LeftReturnQty, ag.nSaleUnits SaleMulti, ag.sSpec sSpec,"
+ "ag.sGoodTypeID GoodTypeID, "
+ "agp.sURL, "
+ "pm.sPromoName, "
+ "pm.sPromoTheme, "
+ "pm.sPromoActionType sPromoType, "
+ "pm.sPromoActionTypeID sPromoTypeID "
+ "from tSalesOrderSubDtl sosd "
+ "left join (select a.sPromoPaperNO, a.sPromoName, a.sPromoTheme, a.sPromoActionTypeID, a.sPromoActionType, b.nGoodsID "
+ " from tYWPromoMain a, tYWPromoDtl b "
+ " where a.sPromoPaperNO = b.sPromoPaperNO "
+ " and a.sPromoPaperNORuleID = b.sPromoPaperNO + isnull(convert(varchar,b.nRuleID),'') "
+ " ) pm on pm.sPromoPaperNO = sosd.sPromoPaperNO and pm.nGoodsID = sosd.nGoodsID "
+ "left join V_GetminAgentGoodsPic agp on agp.nAgentID = sosd.nAgentID and agp.nGoodsID = sosd.nGoodsID and agp.sPicTypeID = 1 "
+ "left join tAgentContractGoods ag on sosd.sAgentContractNO = ag.sAgentContractNO and sosd.nGoodsID = ag.nGoodsID "
+ " where sosd.sSubOrderID = ?";
String sql = "" + "select "
+ "sosd.*, PromoSalePrice=CONVERT(NUMERIC(12,2),ROUND((sosd.nSaleAmount)/sosd.nSaleQty,2)),OriginaSaleAmount=sosd.nSaleAmount+sosd.nDisAmount,ISGift = sosd.nTag&1, "
+ "sosd.nSendQty - isnull(sosd.nReturnQty,0) LeftReturnQty, ag.nSaleUnits SaleMulti, ag.sSpec sSpec,"
+ "ag.sGoodTypeID GoodTypeID, " + "agp.sURL, " + "pm.sPromoName, " + "pm.sPromoTheme, "
+ "pm.sPromoActionType sPromoType, " + "pm.sPromoActionTypeID sPromoTypeID "
+ "from tSalesOrderSubDtl sosd "
+ "left join (select a.sPromoPaperNO, a.sPromoName, a.sPromoTheme, a.sPromoActionTypeID, a.sPromoActionType, b.nGoodsID "
+ " from tYWPromoMain a, tYWPromoDtl b "
+ " where a.sPromoPaperNO = b.sPromoPaperNO "
+ " and a.sPromoPaperNORuleID = b.sPromoPaperNO + isnull(convert(varchar,b.nRuleID),'') "
+ " and a.nTag&1=0 "
+ " and b.nTag&1=0 "
+ " ) pm on pm.sPromoPaperNO = sosd.sPromoPaperNO and pm.nGoodsID = sosd.nGoodsID "
+ "left join V_GetminAgentGoodsPic agp on agp.nAgentID = sosd.nAgentID and agp.nGoodsID = sosd.nGoodsID and agp.sPicTypeID = 1 "
+ "left join tAgentContractGoods ag on sosd.sAgentContractNO = ag.sAgentContractNO and sosd.nGoodsID = ag.nGoodsID "
+ " where sosd.sSubOrderID = ?";
List<Map<String, Object>> dtlList = jdbcTemplate.queryForList(sql, subOrderID);
Map<String, Object> deliver = jdbcTemplate.queryForMap("SELECT sum(a.nNum) nTotalCount, sum(a.nPrice * a.nNum) nTotalAmount FROM tSalesOrderDeliverSubDtl a where a.sSubOrderID = ?", subOrderID);
Map<String, Object> deliver = jdbcTemplate.queryForMap(
"SELECT sum(a.nNum) nTotalCount, sum(a.nPrice * a.nNum) nTotalAmount FROM tSalesOrderDeliverSubDtl a where a.sSubOrderID = ?",
subOrderID);
String sql3 = "select sSubOrderID, nOrderMoney, sAocOrderID, sAocOrderNumber, nOrderNum, nPickupNum, sExpressNO, sExpressName from tSalesOrderDeliverSub where nTag&1 = 0 and sSubOrderID = ?";
List<Map<String, Object>> deliverSubList = jdbcTemplate.queryForList(sql3, subOrderID);
return Rjx.jsonOk().set("deliver", deliver).set("deliverList", deliverSubList).set("order", orderMap).set("subOrder", subOrderMap).set("list", dtlList).toJson();
return Rjx.jsonOk().set("deliver", deliver).set("deliverList", deliverSubList).set("order", orderMap)
.set("subOrder", subOrderMap).set("list", dtlList).toJson();
}
@Override
public void cancelOrder(String sSalesOrderID) {
jdbcTemplate.executeMutil("exec up_CancelledSalesOrder '" + sSalesOrderID + "'");
}
@Override
@Transactional
public String submitByGroup(String orgNo, String shopNo, String promoPaperNO, String promoGroupNO, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo) {
public String submitByGroup(String orgNo, String shopNo, String promoPaperNO, String promoGroupNO, Integer saleQty,
String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType,
String bankAccount, String bankAccountName, String revBankType, String revBankAccount,
String revBankAccountNo, String memo) {
XException.assertNotBlank(orgNo, "OrgNO不能为空");
XException.assertNotBlank(shopNo, "ShopNO不能为空");
XException.assertNotBlank(promoPaperNO, "PromoPaperNO不能为空");
......@@ -445,95 +421,84 @@ public class OrderServiceImpl implements OrderService {
XException.assertNotBlank(saleQty, "SaleQty不能为空");
XException.assertNotBlank(addrId, "AddrID不能为空");
XException.assertNotBlank(payTypeId, "PayTypeID不能为空");
String stockSql = "select og.sWarehouseNO, og.sAgentContractNO, og.nGoodsID, og.nStockQty, og.nLockedQty from tPromoRuleGoods prg, V_OrgGoods og where prg.sAgentContractNO = og.sAgentContractNO and prg.nGoodsID = og.nGoodsID and og.sOrgNO = ? and prg.sPromoPaperNO = ? and prg.sPromoGroupNO = ?";
List<Map<String, Object>> stockList = jdbcTemplate.queryForList(stockSql, orgNo, promoPaperNO, promoGroupNO);
Map<String, Map<String, Object>> stockMM = Util.listToMM(stockList, "_", "sAgentContractNO", "nGoodsID");
Map<String, Object> custMap = jdbcTemplate.queryForMap("select c.* from tCustomer c, tShop s where c.sCustNO = s.sCustNO and s.sShopNO = ? and s.sOrgNO = ?", shopNo, orgNo);
String sCustTypeID = (String)custMap.get("sCustTypeID");
String sCustNO = (String)custMap.get("sCustNO");
Map<String, Object> custMap = jdbcTemplate.queryForMap(
"select c.* from tCustomer c, tShop s where c.sCustNO = s.sCustNO and s.sShopNO = ? and s.sOrgNO = ?",
shopNo, orgNo);
String sCustTypeID = (String) custMap.get("sCustTypeID");
String sCustNO = (String) custMap.get("sCustNO");
this.saveOrderBankAccount(sCustNO, bankType, bankAccount);
Map<String, Object> addrMap = jdbcTemplate.queryForMap("select * from tCustAddress where sAddrID = ?", addrId);
List<String> address = new ArrayList<String>();
address.add((String)addrMap.get("sProvince"));
address.add((String)addrMap.get("sCity"));
address.add((String)addrMap.get("sDistrict"));
address.add((String)addrMap.get("sAddress"));
address.add((String) addrMap.get("sProvince"));
address.add((String) addrMap.get("sCity"));
address.add((String) addrMap.get("sDistrict"));
address.add((String) addrMap.get("sAddress"));
address = address.stream().filter(o -> o != null).collect(Collectors.toList());
String sAddress = StringUtil.join(" ", address);
String sMobile = (String)addrMap.get("sMobile");
String sEmail = (String)addrMap.get("sEmail");
String sPostalcode = (String)addrMap.get("sPostalcode");
String sContacts = (String)addrMap.get("sContacts");
String sql = "" +
"SELECT DISTINCT " +
" GoodsID = b.nGoodsID, " +
" GoodsDesc = ag.sGoodsDesc, " +
" AgentContractNO = ag.sAgentContractNO, " +
" RealSalePrice = isnull(ap.nRealSalePrice, ag.nRealSalePrice), " +
" AgentID = ag.nAgentID, " +
" Barcode = ag.sMainBarcode, " +
" MeetQty = b.nMeetQty, " +
" Price = b.nPrice " +
" FROM tPromo a, tPromoRuleGoods b, tPromoCustBWList c, tAgent at, tAgentContractGoods ag " +
" LEFT JOIN tAgentCustTypePrice ap ON ap.sCustTypeID = c.sShopNO and ap.sAgentContractNO = ag.sAgentContractNO and ap.nGoodsID = ag.nGoodsID " +
" WHERE " +
" a.sPromoPaperNO = c.sPromoPaperNO " +
" AND a.sPromoPaperNO = b.sPromoPaperNO " +
" AND b.sAgentContractNO = ag.sAgentContractNO " +
" AND ag.nAgentID = at.nAgentID " +
" AND b.nGoodsID = ag.nGoodsID " +
" AND a.sPromoActionTypeID = '3' " +
" AND a.nTag&3=2 " +
" AND b.nTag&3=2 " +
" AND getdate() BETWEEN a.dPromoBeginDate AND a.dPromoEndDate " +
" AND CASE WHEN nUseCycle&1 = 1 THEN '1,' ELSE '' END + " +
" CASE WHEN nUseCycle&2 = 2 THEN '2,' ELSE '' END + " +
" CASE WHEN nUseCycle&4 = 4 THEN '3,' ELSE '' END + " +
" CASE WHEN nUseCycle&8 = 8 THEN '4,' ELSE '' END + " +
" CASE WHEN nUseCycle&16 = 16 THEN '5,' ELSE '' END + " +
" CASE WHEN nUseCycle&32 = 32 THEN '6,' ELSE '' END + " +
" CASE WHEN nUseCycle&64 = 64 THEN '7' ELSE '' END LIKE '%' + convert(VARCHAR,datepart(weekday,getdate())) + '%' " +
" AND a.sPromoPaperNO = ? " +
" AND b.sPromoGroupNO = ? " +
" AND c.sShopNO = ? ";
List<Map<String, Object>> goodsList = jdbcTemplate.queryForList(sql.replaceAll("\\s+", " "), promoPaperNO, promoGroupNO, sCustTypeID);
if(goodsList.size() == 0) {
String sMobile = (String) addrMap.get("sMobile");
String sEmail = (String) addrMap.get("sEmail");
String sPostalcode = (String) addrMap.get("sPostalcode");
String sContacts = (String) addrMap.get("sContacts");
String sql = "" + "SELECT DISTINCT " + " GoodsID = b.nGoodsID, " + " GoodsDesc = ag.sGoodsDesc, "
+ " AgentContractNO = ag.sAgentContractNO, "
+ " RealSalePrice = isnull(ap.nRealSalePrice, ag.nRealSalePrice), "
+ " AgentID = ag.nAgentID, " + " Barcode = ag.sMainBarcode, "
+ " MeetQty = b.nMeetQty, " + " Price = b.nPrice "
+ " FROM tPromo a, tPromoRuleGoods b, tPromoCustBWList c, tAgent at, tAgentContractGoods ag "
+ " LEFT JOIN tAgentCustTypePrice ap ON ap.sCustTypeID = c.sShopNO and ap.sAgentContractNO = ag.sAgentContractNO and ap.nGoodsID = ag.nGoodsID "
+ " WHERE " + " a.sPromoPaperNO = c.sPromoPaperNO " + " AND a.sPromoPaperNO = b.sPromoPaperNO "
+ " AND b.sAgentContractNO = ag.sAgentContractNO " + " AND ag.nAgentID = at.nAgentID "
+ " AND b.nGoodsID = ag.nGoodsID " + " AND a.sPromoActionTypeID = '3' " + " AND a.nTag&3=2 "
+ " AND b.nTag&3=2 " + " AND getdate() BETWEEN a.dPromoBeginDate AND a.dPromoEndDate "
+ " AND CASE WHEN nUseCycle&1 = 1 THEN '1,' ELSE '' END + "
+ " CASE WHEN nUseCycle&2 = 2 THEN '2,' ELSE '' END + "
+ " CASE WHEN nUseCycle&4 = 4 THEN '3,' ELSE '' END + "
+ " CASE WHEN nUseCycle&8 = 8 THEN '4,' ELSE '' END + "
+ " CASE WHEN nUseCycle&16 = 16 THEN '5,' ELSE '' END + "
+ " CASE WHEN nUseCycle&32 = 32 THEN '6,' ELSE '' END + "
+ " CASE WHEN nUseCycle&64 = 64 THEN '7' ELSE '' END LIKE '%' + convert(VARCHAR,datepart(weekday,getdate())) + '%' "
+ " AND a.sPromoPaperNO = ? " + " AND b.sPromoGroupNO = ? " + " AND c.sShopNO = ? ";
List<Map<String, Object>> goodsList = jdbcTemplate.queryForList(sql.replaceAll("\\s+", " "), promoPaperNO,
promoGroupNO, sCustTypeID);
if (goodsList.size() == 0) {
throw new XException("对不起,您不能购买该礼包");
}
BigDecimal Qty = BigDecimal.valueOf(saleQty);
BigDecimal nOrderTotalAmount = BigDecimal.ZERO;
BigDecimal nPayTotalAmount = BigDecimal.ZERO;
BigDecimal nTotalSaleQty = BigDecimal.ZERO;
List<Object[]> batchArgs = new ArrayList<Object[]>();
for(Map<String, Object> gMap : goodsList) {
String GoodsDesc = (String)gMap.get("GoodsDesc");
String sAgentContractNO = (String)gMap.get("AgentContractNO");
Integer nGoodsID = ((Number)gMap.get("GoodsID")).intValue();
for (Map<String, Object> gMap : goodsList) {
String GoodsDesc = (String) gMap.get("GoodsDesc");
String sAgentContractNO = (String) gMap.get("AgentContractNO");
Integer nGoodsID = ((Number) gMap.get("GoodsID")).intValue();
String key = sAgentContractNO + "_" + nGoodsID;
Map<String, Object> stockMap = stockMM.get(key);
if(stockMap == null) {
if (stockMap == null) {
throw new XException("活动商品库存异常");
}
BigDecimal nStockQty = (BigDecimal)stockMap.get("nStockQty");
BigDecimal nLockedQty = (BigDecimal)stockMap.get("nLockedQty");
BigDecimal MeetQty = (BigDecimal)gMap.get("MeetQty");
BigDecimal nStockQty = (BigDecimal) stockMap.get("nStockQty");
BigDecimal nLockedQty = (BigDecimal) stockMap.get("nLockedQty");
BigDecimal MeetQty = (BigDecimal) gMap.get("MeetQty");
BigDecimal nTotalMeetQty = MeetQty.multiply(Qty);
if(nStockQty.subtract(nLockedQty).compareTo(nTotalMeetQty) < 0) {
if (nStockQty.subtract(nLockedQty).compareTo(nTotalMeetQty) < 0) {
throw new XException("商品[" + GoodsDesc + "]库存不足");
}
String sWarehouseNO = (String)stockMap.get("sWarehouseNO");
batchArgs.add(new Object[] {nTotalMeetQty, sAgentContractNO, nGoodsID, sWarehouseNO});
BigDecimal RealSalePrice = (BigDecimal)gMap.get("RealSalePrice");
BigDecimal Price = (BigDecimal)gMap.get("Price");
String sWarehouseNO = (String) stockMap.get("sWarehouseNO");
batchArgs.add(new Object[] { nTotalMeetQty, sAgentContractNO, nGoodsID, sWarehouseNO });
BigDecimal RealSalePrice = (BigDecimal) gMap.get("RealSalePrice");
BigDecimal Price = (BigDecimal) gMap.get("Price");
BigDecimal TotalAmount = RealSalePrice.multiply(nTotalMeetQty);
BigDecimal PayAmount = Price.multiply(nTotalMeetQty);
nOrderTotalAmount = nOrderTotalAmount.add(TotalAmount);
......@@ -541,9 +506,11 @@ public class OrderServiceImpl implements OrderService {
nTotalSaleQty = nTotalSaleQty.add(nTotalMeetQty);
gMap.put("WarehouseNO", sWarehouseNO);
}
jdbcTemplate.batchUpdate("update tAgentStockOnline set nLockedQty = (nLockedQty + ?) where sAgentContractNO = ? and nGoodsID = ? and sWarehouseNO = ?", batchArgs);
BigDecimal nTotalDisAmount = nOrderTotalAmount.subtract(nPayTotalAmount);
jdbcTemplate.batchUpdate(
"update tAgentStockOnline set nLockedQty = (nLockedQty + ?) where sAgentContractNO = ? and nGoodsID = ? and sWarehouseNO = ?",
batchArgs);
BigDecimal nTotalDisAmount = nOrderTotalAmount.subtract(nPayTotalAmount);
BigDecimal nTotalSaleAmount = nPayTotalAmount;
TSalesOrder order = new TSalesOrder();
order.setsSalesOrderID(System.currentTimeMillis() + "");
......@@ -577,7 +544,8 @@ public class OrderServiceImpl implements OrderService {
order.setsDeliveryType("送货");
order.setsDeliveryTypeID("1");
order.setsSalesOrderPayTypeID(payTypeId);
order.setsSalesOrderPayType("1".equals(payTypeId) ? "货到付款" : ("4".equals(payTypeId) ? "在线支付" : ("2".equals(payTypeId) ? "线下转账" : "")));
order.setsSalesOrderPayType("1".equals(payTypeId) ? "货到付款"
: ("4".equals(payTypeId) ? "在线支付" : ("2".equals(payTypeId) ? "线下转账" : "")));
order.setsTerminalTypeID(terminal.equals("wechat") ? "WX" : terminal);
order.setsTerminalType(terminal.equals("wechat") ? "微信" : terminal);
order.setsFormID(formId);
......@@ -585,27 +553,27 @@ public class OrderServiceImpl implements OrderService {
order.setsB2BOrderType("组合礼包订单");
order.setsOrderMemo(memo);
jdbcTemplate.save(order);
List<TSalesOrderDtl> list = new ArrayList<TSalesOrderDtl>();
Integer index = 1;
for(Map<String, Object> gMap : goodsList) {
for (Map<String, Object> gMap : goodsList) {
TSalesOrderDtl dtl = new TSalesOrderDtl();
String sSalesOrderID = order.getsSalesOrderID();
Date dUpdate = new Date();
BigDecimal MeetQty = (BigDecimal)gMap.get("MeetQty");
Integer nAgentID = ((Number)gMap.get("AgentID")).intValue();
BigDecimal RealSalePrice = (BigDecimal)gMap.get("RealSalePrice");
BigDecimal Price = (BigDecimal)gMap.get("Price");
BigDecimal MeetQty = (BigDecimal) gMap.get("MeetQty");
Integer nAgentID = ((Number) gMap.get("AgentID")).intValue();
BigDecimal RealSalePrice = (BigDecimal) gMap.get("RealSalePrice");
BigDecimal Price = (BigDecimal) gMap.get("Price");
BigDecimal nDisAmount = RealSalePrice.subtract(Price).multiply(MeetQty).multiply(Qty);
BigDecimal nSaleAmount = Price.multiply(MeetQty).multiply(Qty);
BigDecimal nSalePrice = Price;
BigDecimal nSaleQty = MeetQty.multiply(Qty);
BigDecimal nExpressFee = BigDecimal.ZERO;
Integer nGoodsID = ((Number)gMap.get("GoodsID")).intValue();
String sAgentContractNO = (String)gMap.get("AgentContractNO");
String sBarcode = (String)gMap.get("Barcode");
String sGoodsDesc = (String)gMap.get("GoodsDesc");
String sWarehouseNO = (String)gMap.get("WarehouseNO");
Integer nGoodsID = ((Number) gMap.get("GoodsID")).intValue();
String sAgentContractNO = (String) gMap.get("AgentContractNO");
String sBarcode = (String) gMap.get("Barcode");
String sGoodsDesc = (String) gMap.get("GoodsDesc");
String sWarehouseNO = (String) gMap.get("WarehouseNO");
dtl.setsSalesOrderID(sSalesOrderID);
dtl.setdUpdate(dUpdate);
dtl.setnAgentID(nAgentID);
......@@ -630,14 +598,16 @@ public class OrderServiceImpl implements OrderService {
list.add(dtl);
}
jdbcTemplate.batchSave(list);
//this.sendWxMessage(order.getsSalesOrderID());
// this.sendWxMessage(order.getsSalesOrderID());
return order.getsSalesOrderID();
}
@Override
@Transactional
public String submitByZhc(String orgNo, String shopNo, Integer planId, Integer saleQty, String addrId, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo) {
public String submitByZhc(String orgNo, String shopNo, Integer planId, Integer saleQty, String addrId,
String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount,
String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo) {
XException.assertNotBlank(orgNo, "OrgNO不能为空");
XException.assertNotBlank(shopNo, "ShopNO不能为空");
XException.assertNotBlank(planId, "PlanID不能为空");
......@@ -645,66 +615,48 @@ public class OrderServiceImpl implements OrderService {
XException.assertNotBlank(addrId, "AddrID不能为空");
XException.assertNotBlank(payTypeId, "PayTypeID不能为空");
XException.assertNotBlank(terminal, "Terminal不能为空");
BigDecimal Qty = BigDecimal.valueOf(saleQty);
Map<String, Object> custMap = jdbcTemplate.queryForMap("select c.* from tCustomer c, tShop s where c.sCustNO = s.sCustNO and s.sShopNO = ?", shopNo);
String sCustNO = (String)custMap.get("sCustNO");
Map<String, Object> custMap = jdbcTemplate.queryForMap(
"select c.* from tCustomer c, tShop s where c.sCustNO = s.sCustNO and s.sShopNO = ?", shopNo);
String sCustNO = (String) custMap.get("sCustNO");
this.saveOrderBankAccount(sCustNO, bankType, bankAccount);
Map<String, Object> addrMap = jdbcTemplate.queryForMap("select * from tCustAddress where sAddrID = ?", addrId);
List<String> address = new ArrayList<String>();
address.add((String)addrMap.get("sProvince"));
address.add((String)addrMap.get("sCity"));
address.add((String)addrMap.get("sDistrict"));
address.add((String)addrMap.get("sAddress"));
address.add((String) addrMap.get("sProvince"));
address.add((String) addrMap.get("sCity"));
address.add((String) addrMap.get("sDistrict"));
address.add((String) addrMap.get("sAddress"));
address = address.stream().filter(o -> o != null).collect(Collectors.toList());
String sAddress = StringUtil.join(" ", address);
String sMobile = (String)addrMap.get("sMobile");
String sEmail = (String)addrMap.get("sEmail");
String sPostalcode = (String)addrMap.get("sPostalcode");
String sContacts = (String)addrMap.get("sContacts");
String sqlplan = ""
+ "SELECT " +
" t.*, " +
" og.nAgentID, " +
" og.sWarehouseNO, " +
" og.sGoodsDesc, " +
" og.sMainBarcode " +
"FROM " +
" ( " +
" SELECT " +
" zp.*, " +
" j.dStartDate, " +
" j.dEndDate, " +
" j.nProjectAmount, " +
" j.sProjectName, " +
" j.sOrgNO " +
" FROM " +
" tZHCPlan zp, " +
" tZHCProject j " +
" WHERE " +
" zp.nPlanID = ? " +
" AND zp.nProjectID = j.nProjectID " +
" AND j.sOrgNO = ? " +
" AND j.dStartDate <= getdate( ) " +
" AND j.dEndDate >= getdate( ) " +
" ) t " +
" LEFT JOIN V_OrgGoods og ON og.sOrgNO = t.sOrgNO " +
" AND og.sAgentContractNO = t.sAgentContractNO " +
" AND og.nGoodsID = t.nGoodsID";
String sMobile = (String) addrMap.get("sMobile");
String sEmail = (String) addrMap.get("sEmail");
String sPostalcode = (String) addrMap.get("sPostalcode");
String sContacts = (String) addrMap.get("sContacts");
String sqlplan = "" + "SELECT " + " t.*, " + " og.nAgentID, " + " og.sWarehouseNO, " + " og.sGoodsDesc, "
+ " og.sMainBarcode " + "FROM " + " ( " + " SELECT " + " zp.*, " + " j.dStartDate, "
+ " j.dEndDate, " + " j.nProjectAmount, " + " j.sProjectName, " + " j.sOrgNO "
+ " FROM " + " tZHCPlan zp, " + " tZHCProject j " + " WHERE " + " zp.nPlanID = ? "
+ " AND zp.nProjectID = j.nProjectID " + " AND j.sOrgNO = ? "
+ " AND j.dStartDate <= getdate( ) " + " AND j.dEndDate >= getdate( ) " + " ) t "
+ " LEFT JOIN V_OrgGoods og ON og.sOrgNO = t.sOrgNO "
+ " AND og.sAgentContractNO = t.sAgentContractNO " + " AND og.nGoodsID = t.nGoodsID";
Map<String, Object> gMap = jdbcTemplate.queryForMap(sqlplan.replaceAll("\\s+", " "), planId, orgNo);
BigDecimal nPrice = (BigDecimal)gMap.get("nPrice");
BigDecimal nPrice = (BigDecimal) gMap.get("nPrice");
BigDecimal nTotalSaleAmount = nPrice.multiply(Qty);
BigDecimal nPlanStock = (BigDecimal)gMap.get("nPlanStock");
Map<String, Object> planSum = jdbcTemplate.queryForMap("select sum(nTotalSaleQty) nOrderQty, sum(nTotalSaleAmount) nOrderAmount from tSalesOrder where nPlanID = ? and nOrderStatus&1 = 0", planId);
BigDecimal nOrderQty = (BigDecimal)planSum.get("nOrderQty");
BigDecimal nPlanStock = (BigDecimal) gMap.get("nPlanStock");
Map<String, Object> planSum = jdbcTemplate.queryForMap(
"select sum(nTotalSaleQty) nOrderQty, sum(nTotalSaleAmount) nOrderAmount from tSalesOrder where nPlanID = ? and nOrderStatus&1 = 0",
planId);
BigDecimal nOrderQty = (BigDecimal) planSum.get("nOrderQty");
nOrderQty = nOrderQty == null ? BigDecimal.ZERO : nOrderQty;
nPlanStock = nPlanStock == null ? BigDecimal.ZERO : nPlanStock;
if(nOrderQty.compareTo(nPlanStock) == 0) {
if (nOrderQty.compareTo(nPlanStock) == 0) {
throw new XException("该档众筹产品已售罄,请重新选择");
}
if(nOrderQty.add(Qty).compareTo(nPlanStock) > 0) {
if (nOrderQty.add(Qty).compareTo(nPlanStock) > 0) {
throw new XException("该档众筹产品数量不足,请重新选择数量");
}
TSalesOrder order = new TSalesOrder();
......@@ -740,7 +692,8 @@ public class OrderServiceImpl implements OrderService {
order.setsDeliveryType("送货");
order.setsDeliveryTypeID("1");
order.setsSalesOrderPayTypeID(payTypeId);
order.setsSalesOrderPayType("1".equals(payTypeId) ? "货到付款" : ("4".equals(payTypeId) ? "在线支付" : ("2".equals(payTypeId) ? "线下转账" : "")));
order.setsSalesOrderPayType("1".equals(payTypeId) ? "货到付款"
: ("4".equals(payTypeId) ? "在线支付" : ("2".equals(payTypeId) ? "线下转账" : "")));
order.setsTerminalTypeID(terminal.equals("wechat") ? "WX" : terminal);
order.setsTerminalType(terminal.equals("wechat") ? "微信" : terminal);
order.setsFormID(formId);
......@@ -748,16 +701,16 @@ public class OrderServiceImpl implements OrderService {
order.setsB2BOrderType("众筹订单");
order.setsOrderMemo(memo);
jdbcTemplate.save(order);
TSalesOrderDtl dtl = new TSalesOrderDtl();
String sSalesOrderID = order.getsSalesOrderID();
Date dUpdate = new Date();
Integer nGoodsID = ((Number)gMap.get("nGoodsID")).intValue();
String sAgentContractNO = (String)gMap.get("sAgentContractNO");
String sBarcode = (String)gMap.get("sMainBarcode");
String sGoodsDesc = (String)gMap.get("sGoodsDesc");
String sWarehouseNO = (String)gMap.get("sWarehouseNO");
Integer nAgentID = ((Number)gMap.get("nAgentID")).intValue();
Integer nGoodsID = ((Number) gMap.get("nGoodsID")).intValue();
String sAgentContractNO = (String) gMap.get("sAgentContractNO");
String sBarcode = (String) gMap.get("sMainBarcode");
String sGoodsDesc = (String) gMap.get("sGoodsDesc");
String sWarehouseNO = (String) gMap.get("sWarehouseNO");
Integer nAgentID = ((Number) gMap.get("nAgentID")).intValue();
dtl.setsSalesOrderID(sSalesOrderID);
dtl.setdUpdate(dUpdate);
dtl.setnAgentID(nAgentID);
......@@ -777,23 +730,26 @@ public class OrderServiceImpl implements OrderService {
dtl.setsSalesOrderID(sSalesOrderID);
dtl.setsWarehouseNO(sWarehouseNO);
jdbcTemplate.save(dtl);
{
Long nProjectID = jdbcTemplate.queryForLong("select nProjectID from tZHCPlan where nPlanID = ?", planId);
String sql = "select count(so.sSalesOrderID) nSalePaperQty, isnull(sum(so.nTotalSaleQty), 0) nSaleQty, isnull(sum(so.nTotalSaleAmount), 0) nSaleAmount from tSalesOrder so, tZHCPlan p where so.sB2BOrderTypeID = '3' and so.nTag&1 = 0 and so.nPlanID = p.nPlanID and p.nProjectID = ?";
Map<String, Object> map = jdbcTemplate.queryForMap(sql, nProjectID);
Integer nSalePaperQty = ((Number)map.get("nSalePaperQty")).intValue();
BigDecimal nSaleQty = (BigDecimal)map.get("nSaleQty");
BigDecimal nSaleAmount = (BigDecimal)map.get("nSaleAmount");
Integer nSalePaperQty = ((Number) map.get("nSalePaperQty")).intValue();
BigDecimal nSaleQty = (BigDecimal) map.get("nSaleQty");
BigDecimal nSaleAmount = (BigDecimal) map.get("nSaleAmount");
String sqlUpdate = "update tZHCProject set nSalePaperQty = ?, nSaleQty = ?, nSaleAmount = ? where nProjectID = ?";
jdbcTemplate.executeUpdate(sqlUpdate, nSalePaperQty, nSaleQty, nSaleAmount, nProjectID);
jdbcTemplate.executeUpdate(sqlUpdate, nSalePaperQty, nSaleQty, nSaleAmount, nProjectID);
}
//this.sendWxMessage(order.getsSalesOrderID());
// this.sendWxMessage(order.getsSalesOrderID());
return order.getsSalesOrderID();
}
@Override
public String submitByMdzs(String orgNo, String shopNo, String contractNo, Integer goodsId, Integer saleQty, String addrId, String email, String payTypeId, String terminal, String salesmanNo, String formId, String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount, String revBankAccountNo, String memo) {
public String submitByMdzs(String orgNo, String shopNo, String contractNo, Integer goodsId, Integer saleQty,
String addrId, String email, String payTypeId, String terminal, String salesmanNo, String formId,
String bankType, String bankAccount, String bankAccountName, String revBankType, String revBankAccount,
String revBankAccountNo, String memo) {
XException.assertNotBlank(orgNo, "OrgNO不能为空");
XException.assertNotBlank(shopNo, "ShopNO不能为空");
XException.assertNotBlank(contractNo, "ContractNO不能为空");
......@@ -802,49 +758,50 @@ public class OrderServiceImpl implements OrderService {
XException.assertNotBlank(addrId, "AddrID不能为空");
XException.assertNotBlank(payTypeId, "PayTypeID不能为空");
XException.assertNotBlank(terminal, "Terminal不能为空");
Map<String, Object> custMap = jdbcTemplate.queryForMap("select c.* from tCustomer c, tShop s where c.sCustNO = s.sCustNO and s.sShopNO = ?", shopNo);
String sCustTypeID = (String)custMap.get("sCustTypeID");
String sCustNO = (String)custMap.get("sCustNO");
Map<String, Object> custMap = jdbcTemplate.queryForMap(
"select c.* from tCustomer c, tShop s where c.sCustNO = s.sCustNO and s.sShopNO = ?", shopNo);
String sCustTypeID = (String) custMap.get("sCustTypeID");
String sCustNO = (String) custMap.get("sCustNO");
this.saveOrderBankAccount(sCustNO, bankType, bankAccount);
BigDecimal Qty = BigDecimal.valueOf(saleQty);
Map<String, Object> addrMap = jdbcTemplate.queryForMap("select * from tCustAddress where sAddrID = ?", addrId);
List<String> address = new ArrayList<String>();
address.add((String)addrMap.get("sProvince"));
address.add((String)addrMap.get("sCity"));
address.add((String)addrMap.get("sDistrict"));
address.add((String)addrMap.get("sAddress"));
address.add((String) addrMap.get("sProvince"));
address.add((String) addrMap.get("sCity"));
address.add((String) addrMap.get("sDistrict"));
address.add((String) addrMap.get("sAddress"));
address = address.stream().filter(o -> o != null).collect(Collectors.toList());
String sAddress = StringUtil.join(" ", address);
String sMobile = (String)addrMap.get("sMobile");
String sPostalcode = (String)addrMap.get("sPostalcode");
String sContacts = (String)addrMap.get("sContacts");
String sMobile = (String) addrMap.get("sMobile");
String sPostalcode = (String) addrMap.get("sPostalcode");
String sContacts = (String) addrMap.get("sContacts");
String gSql = "select t.*, ap.nRealSalePrice nApSalePrice from V_OrgGoods t left join tAgentCustTypePrice ap on ap.sCustTypeID = ? and ap.sAgentContractNO = t.sAgentContractNO and ap.nGoodsID = t.nGoodsID where t.sOrgNO = ? and t.sAgentContractNO = ? and t.nGoodsID = ?";
Map<String, Object> gMap = jdbcTemplate.queryForMap(gSql, sCustTypeID, orgNo, contractNo, goodsId);
BigDecimal nStockQty = (BigDecimal)gMap.get("nStockQty");
BigDecimal nLockedQty = (BigDecimal)gMap.get("nLockedQty");
BigDecimal nStockQty = (BigDecimal) gMap.get("nStockQty");
BigDecimal nLockedQty = (BigDecimal) gMap.get("nLockedQty");
BigDecimal stock = nStockQty.subtract(nLockedQty);
String sGoodsDesc = (String)gMap.get("sGoodsDesc");
String sAgentContractNO = (String)gMap.get("sAgentContractNO");
Integer nGoodsID = (Integer)gMap.get("nGoodsID");
String sWarehouseNO = (String)gMap.get("sWarehouseNO");
String sBarcode = (String)gMap.get("sMainBarcode");
Integer nAgentID = ((Number)gMap.get("nAgentID")).intValue();
if(stock.compareTo(Qty) < 0) {
String sGoodsDesc = (String) gMap.get("sGoodsDesc");
String sAgentContractNO = (String) gMap.get("sAgentContractNO");
Integer nGoodsID = (Integer) gMap.get("nGoodsID");
String sWarehouseNO = (String) gMap.get("sWarehouseNO");
String sBarcode = (String) gMap.get("sMainBarcode");
Integer nAgentID = ((Number) gMap.get("nAgentID")).intValue();
if (stock.compareTo(Qty) < 0) {
throw new XException("商品[" + sGoodsDesc + "]库存不足");
} else {
String stockSql = "update tAgentStockOnline set nLockedQty = nLockedQty + ? where sAgentContractNO = ? and nGoodsID = ? and sWarehouseNO = ?";
jdbcTemplate.update(stockSql, Qty, sAgentContractNO, nGoodsID, sWarehouseNO);
}
BigDecimal nTotalSaleAmount = BigDecimal.ZERO;
BigDecimal nRealSalePrice = (BigDecimal)gMap.get("nApSalePrice");
if(nRealSalePrice == null) {
nRealSalePrice = (BigDecimal)gMap.get("nRealSalePrice");
BigDecimal nRealSalePrice = (BigDecimal) gMap.get("nApSalePrice");
if (nRealSalePrice == null) {
nRealSalePrice = (BigDecimal) gMap.get("nRealSalePrice");
}
nTotalSaleAmount = nTotalSaleAmount.add(nRealSalePrice.multiply(Qty));
TSalesOrder order = new TSalesOrder();
order.setsSalesOrderID(System.currentTimeMillis() + "");
order.setdLastUpdateTime(new Date());
......@@ -877,7 +834,8 @@ public class OrderServiceImpl implements OrderService {
order.setsDeliveryType("送货");
order.setsDeliveryTypeID("1");
order.setsSalesOrderPayTypeID(payTypeId);
order.setsSalesOrderPayType("1".equals(payTypeId) ? "货到付款" : ("4".equals(payTypeId) ? "在线支付" : ("2".equals(payTypeId) ? "线下转账" : "")));
order.setsSalesOrderPayType("1".equals(payTypeId) ? "货到付款"
: ("4".equals(payTypeId) ? "在线支付" : ("2".equals(payTypeId) ? "线下转账" : "")));
order.setsTerminalTypeID(terminal.equals("wechat") ? "WX" : terminal);
order.setsTerminalType(terminal.equals("wechat") ? "微信" : terminal);
order.setsFormID(formId);
......@@ -885,7 +843,7 @@ public class OrderServiceImpl implements OrderService {
order.setsB2BOrderType("门店装饰订单");
order.setsOrderMemo(memo);
jdbcTemplate.save(order);
TSalesOrderDtl dtl = new TSalesOrderDtl();
String sSalesOrderID = order.getsSalesOrderID();
Date dUpdate = new Date();
......@@ -908,31 +866,25 @@ public class OrderServiceImpl implements OrderService {
dtl.setsSalesOrderID(sSalesOrderID);
dtl.setsWarehouseNO(sWarehouseNO);
jdbcTemplate.save(dtl);
//this.sendWxMessage(order.getsSalesOrderID());
// this.sendWxMessage(order.getsSalesOrderID());
return order.getsSalesOrderID();
}
private void saveOrderBankAccount(String sCustNO, String sBankType, String sBankAccountNO) {
if(StringUtil.isNotBlank(sCustNO, sBankType, sBankAccountNO)) {
String sql = ""
+ "DECLARE @CustNO VARCHAR(36) "
+ "DECLARE @CustName VARCHAR(36) "
+ "DECLARE @BankType VARCHAR(36) "
+ "DECLARE @BankTypeID VARCHAR(36) "
+ "DECLARE @BankAccountNO VARCHAR(36) "
+ "SELECT @CustNO = '" + sCustNO + "' "
+ "SELECT @BankType = '" + sBankType + "' "
+ "SELECT @BankAccountNO = '" + sBankAccountNO + "' "
if (StringUtil.isNotBlank(sCustNO, sBankType, sBankAccountNO)) {
String sql = "" + "DECLARE @CustNO VARCHAR(36) " + "DECLARE @CustName VARCHAR(36) "
+ "DECLARE @BankType VARCHAR(36) " + "DECLARE @BankTypeID VARCHAR(36) "
+ "DECLARE @BankAccountNO VARCHAR(36) " + "SELECT @CustNO = '" + sCustNO + "' "
+ "SELECT @BankType = '" + sBankType + "' " + "SELECT @BankAccountNO = '" + sBankAccountNO + "' "
+ "SELECT @CustName = sCustName FROM tCustomer WHERE sCustNO = @CustNO "
+ "SELECT @BankTypeID = sComID from tCommon where sLangID = '936' and sCommonNO = 'Bank' and sComDesc = @BankType "
+ "SELECT @BankTypeID = ISNULL(@BankTypeID, @BankType) "
+ "SELECT @CustName = ISNULL(@CustName, @CustNO) "
+ "IF NOT EXISTS (SELECT * FROM tCustBank WHERE sCustNO = @CustNO AND sBankAccountNO = @BankAccountNO) "
+ "BEGIN "
+ "INSERT INTO tCustBank "
+ "(sCustNO, sBankTypeID, sBankType, sBankAccountNO, sBankAccount, nTag, sCreateUser, dCreateDate, sConfirmUser, dConfirmDate, dLastUpdateTime) "
+ "VALUES "
+ "(@CustNO, @BankTypeID, @BankType, @BankAccountNO, @CustNO, 0, @CustNO, GETDATE(), @CustNO, GETDATE(), GETDATE())"
+ "BEGIN " + "INSERT INTO tCustBank "
+ "(sCustNO, sBankTypeID, sBankType, sBankAccountNO, sBankAccount, nTag, sCreateUser, dCreateDate, sConfirmUser, dConfirmDate, dLastUpdateTime) "
+ "VALUES "
+ "(@CustNO, @BankTypeID, @BankType, @BankAccountNO, @CustNO, 0, @CustNO, GETDATE(), @CustNO, GETDATE(), GETDATE())"
+ "END";
jdbcTemplate.update(sql);
}
......@@ -940,200 +892,163 @@ public class OrderServiceImpl implements OrderService {
@Override
public void confirmReceipt(String custNo, String subOrderID) {
String sql = ""
+ "DECLARE @CustNO VARCHAR(20) "
+ "DECLARE @SubOrderID VARCHAR(20) "
+ "DECLARE @SalesOrderID VARCHAR(20) "
+ "DECLARE @OrderStatusName VARCHAR(20) "
+ "DECLARE @OrderStatus INT "
+ "DECLARE @TargetStatus INT "
+ "SELECT @CustNO = '" + custNo + "' "
+ "SELECT @SubOrderID = '" + subOrderID + "' "
+ "SELECT @TargetStatus = 16 "
String sql = "" + "DECLARE @CustNO VARCHAR(20) " + "DECLARE @SubOrderID VARCHAR(20) "
+ "DECLARE @SalesOrderID VARCHAR(20) " + "DECLARE @OrderStatusName VARCHAR(20) "
+ "DECLARE @OrderStatus INT " + "DECLARE @TargetStatus INT " + "SELECT @CustNO = '" + custNo + "' "
+ "SELECT @SubOrderID = '" + subOrderID + "' " + "SELECT @TargetStatus = 16 "
+ "SELECT @OrderStatusName = '收货完成' "
+ "SELECT @OrderStatus = nOrderStatus FROM tSalesOrderSub WHERE sSubOrderID = @SubOrderID "
+ "IF @OrderStatus&@TargetStatus = 0 "
+ "BEGIN "
+ "SELECT @SalesOrderID = sSalesOrderID FROM tSalesOrderSub WHERE sSubOrderID = @SubOrderID "
+ "UPDATE tSalesOrderSub SET nOrderStatus = nOrderStatus|@TargetStatus, nOrderStatusName = @OrderStatusName, dLastUpdateTime = GETDATE() WHERE sSubOrderID = @SubOrderID "
+ "UPDATE tSalesOrderSubDtl SET nReceiveQty = td.nSendQty, nReceiveAmount = td.nSendAmount, dLastUpdateTime = GETDATE() FROM tSalesOrderSub t, tSalesOrderSubDtl td WHERE t.sSubOrderID = td.sSubOrderID AND t.sSubOrderID = @SubOrderID AND td.nReceiveQty IS NULL "
+ "DECLARE @Idx INT "
+ "SELECT @Idx = ISNULL(MAX(nIdx), 0) + 1 FROM tSalesOrderSubStatus WHERE sSubOrderID = @SubOrderID "
+ "INSERT INTO tSalesOrderSubStatus "
+ "(sSubOrderID, nIdx, sSalesOrderID, nOrderStatusStep, sOrderStatusName, sOrderStatusUser, dOrderStatusTime, dLastUpdateTime) "
+ "VALUES "
+ "(@SubOrderID, @Idx, @SalesOrderID, @TargetStatus, @OrderStatusName, @CustNO, GETDATE(), GETDATE()) "
+ "exec up_UpdateSalesOrderStatus @SalesOrderID, @SubOrderID, @CustNO, @TargetStatus, @OrderStatusName, @OrderStatusName "
+ "END"
;
+ "IF @OrderStatus&@TargetStatus = 0 " + "BEGIN "
+ "SELECT @SalesOrderID = sSalesOrderID FROM tSalesOrderSub WHERE sSubOrderID = @SubOrderID "
+ "UPDATE tSalesOrderSub SET nOrderStatus = nOrderStatus|@TargetStatus, nOrderStatusName = @OrderStatusName, dLastUpdateTime = GETDATE() WHERE sSubOrderID = @SubOrderID "
+ "UPDATE tSalesOrderSubDtl SET nReceiveQty = td.nSendQty, nReceiveAmount = td.nSendAmount, dLastUpdateTime = GETDATE() FROM tSalesOrderSub t, tSalesOrderSubDtl td WHERE t.sSubOrderID = td.sSubOrderID AND t.sSubOrderID = @SubOrderID AND td.nReceiveQty IS NULL "
+ "DECLARE @Idx INT "
+ "SELECT @Idx = ISNULL(MAX(nIdx), 0) + 1 FROM tSalesOrderSubStatus WHERE sSubOrderID = @SubOrderID "
+ "INSERT INTO tSalesOrderSubStatus "
+ "(sSubOrderID, nIdx, sSalesOrderID, nOrderStatusStep, sOrderStatusName, sOrderStatusUser, dOrderStatusTime, dLastUpdateTime) "
+ "VALUES "
+ "(@SubOrderID, @Idx, @SalesOrderID, @TargetStatus, @OrderStatusName, @CustNO, GETDATE(), GETDATE()) "
+ "exec up_UpdateSalesOrderStatus @SalesOrderID, @SubOrderID, @CustNO, @TargetStatus, @OrderStatusName, @OrderStatusName "
+ "END";
jdbcTemplate.update(sql);
}
@Override
public List<Map<String, Object>> getDeliverSubDetail(String aocOrderID) {
return jdbcTemplate.queryForList("select * from tSalesOrderDeliverSubDtl where nTag&1 = 0 and sAocOrderID = ?", aocOrderID);
return jdbcTemplate.queryForList("select * from tSalesOrderDeliverSubDtl where nTag&1 = 0 and sAocOrderID = ?",
aocOrderID);
}
private void sendWxMessage(String sSalesOrderID) {
/*TSalesOrder order = jdbcTemplate.queryForBean("select * from tSalesOrder where sSalesOrderID = ?", TSalesOrder.class, sSalesOrderID);
String salesmanNo = order.getsSalesmanNO();
String shopNo = order.getsShopNO();
BigDecimal totalAmount = order.getnTotalSaleAmount();
BigDecimal totalSaleQty = order.getnTotalSaleQty();
String payType = order.getsSalesOrderPayType();
Map<String, Object> salesman = null;
try {
salesman = jdbcTemplate.queryForMap("select * from tSalesman where sSalesmanNO = ?", salesmanNo);
} catch (EmptyResultDataAccessException e) {
e.printStackTrace();
}
if(salesman != null) {
String dateString = DateUtil.format(new Date());
Map<String, Object> shop = jdbcTemplate.queryForMap("select * from tShop where sShopNO = ?", shopNo);
String custNo = (String)shop.get("sCustNO");
String shopMemo = (String)shop.get("sMemo");
Map<String, Object> cust = jdbcTemplate.queryForMap("select * from tCustomer where sCustNO = ?", custNo);;
String custName = (String)cust.get("sCustName");
String sCompanyAccountID = (String)salesman.get("sCompanyAccountID");
WxMessage wxMessage = new WxMessage(sCompanyAccountID);
MiniprogramNotice notice = new MiniprogramNotice();
wxMessage.setMiniprogram_notice(notice);
notice.setDescription(dateString);
notice.setTitle("客户订单通知");
notice.setPage("pages/ordermanage/detail/detail?SalesmanNO=" + salesmanNo + "&isShare=1&id=" + sSalesOrderID + "&isActive=0");
Map<Object, Object> params = new LinkedHashMap<Object, Object>();
params.put("订单状态", "待审核");
params.put("客户", custName);
params.put("订单金额", totalAmount);
params.put("商品数量", totalSaleQty);
params.put("支付方式", payType);
params.put("订单时间", dateString);
params.put("备注", StringUtil.isBlank(shopMemo) ? " " : shopMemo);
notice.setContent_item(params);
wxService.sendMessage(wxMessage);
}*/
/*
* TSalesOrder order =
* jdbcTemplate.queryForBean("select * from tSalesOrder where sSalesOrderID = ?"
* , TSalesOrder.class, sSalesOrderID); String salesmanNo =
* order.getsSalesmanNO(); String shopNo = order.getsShopNO(); BigDecimal
* totalAmount = order.getnTotalSaleAmount(); BigDecimal totalSaleQty =
* order.getnTotalSaleQty(); String payType = order.getsSalesOrderPayType();
* Map<String, Object> salesman = null; try { salesman =
* jdbcTemplate.queryForMap("select * from tSalesman where sSalesmanNO = ?",
* salesmanNo); } catch (EmptyResultDataAccessException e) {
* e.printStackTrace(); } if(salesman != null) { String dateString =
* DateUtil.format(new Date()); Map<String, Object> shop =
* jdbcTemplate.queryForMap("select * from tShop where sShopNO = ?", shopNo);
* String custNo = (String)shop.get("sCustNO"); String shopMemo =
* (String)shop.get("sMemo"); Map<String, Object> cust =
* jdbcTemplate.queryForMap("select * from tCustomer where sCustNO = ?",
* custNo);; String custName = (String)cust.get("sCustName"); String
* sCompanyAccountID = (String)salesman.get("sCompanyAccountID"); WxMessage
* wxMessage = new WxMessage(sCompanyAccountID); MiniprogramNotice notice = new
* MiniprogramNotice(); wxMessage.setMiniprogram_notice(notice);
* notice.setDescription(dateString); notice.setTitle("客户订单通知");
* notice.setPage("pages/ordermanage/detail/detail?SalesmanNO=" + salesmanNo +
* "&isShare=1&id=" + sSalesOrderID + "&isActive=0"); Map<Object, Object> params
* = new LinkedHashMap<Object, Object>(); params.put("订单状态", "待审核");
* params.put("客户", custName); params.put("订单金额", totalAmount);
* params.put("商品数量", totalSaleQty); params.put("支付方式", payType);
* params.put("订单时间", dateString); params.put("备注", StringUtil.isBlank(shopMemo)
* ? " " : shopMemo); notice.setContent_item(params);
* wxService.sendMessage(wxMessage); }
*/
}
@Override
public RespObject queryRefundOrderList(String orgNo, String shopNo, Integer refundStatus, String langID, Page page) {
public RespObject queryRefundOrderList(String orgNo, String shopNo, Integer refundStatus, String langID,
Page page) {
List<Map<String, Object>> sortList = new ArrayList<Map<String, Object>>();
int saleReturnDays = 0;
try {
String dSql = "select SaleReturnDays = convert(int, sValue1) FROM tSystemCtrl WHERE sCode = 'SaleReturnDays' ";
String dSql = "select SaleReturnDays = convert(int, sValue1) FROM tSystemCtrl WHERE sCode = 'SaleReturnDays' ";
saleReturnDays = jdbcTemplate.queryForInt(dSql);
} catch (Exception e) {
}
String sql = "select " +
" SalesOrderID = a.sSalesOrderID, " +
" SubOrderID = a.sSubOrderID, " +
" OrderDate = a.dOrderDate, " +
" SalesOrderTypeID = a.sSalesOrderTypeID," +
" SalesOrderType = a.sSalesOrderType," +
" TotalSaleQty = a.nTotalSaleQty," +
" TotalSaleAmount = a.nTotalSaleAmount," +
" TotalDisAmount = a.nTotalDisAmount," +
" DeliveryTypeID = a.sDeliveryTypeID," +
" DeliveryType = a.sDeliveryType," +
" Contacts = a.sContacts," +
" Mobile = a.sMobile," +
" Address = a.sAddress," +
" ExpressFee = a.nExpressFee," +
" OrderStatus = a.nOrderStatus," +
" OrderStatusName = a.nOrderStatusName," +
" OrderMemo = a.sOrderMemo" +
" from tSalesOrderSub a "
+ " where a.sShopNO = '"+shopNo+"' " ;
if(refundStatus == 1) { /*查询指定状态订单:1=申请售后*/
sql += " and a.sSalesOrderTypeID = '0' "
+ " and a.sB2BOrderTypeID = '1' "
+ " and a.nOrderStatus&1 = 0 "
+ " and (a.nOrderStatus&16=16 or nOrderStatus&4=0) "
+ " and (datediff(dd, a.dOrderDate, getdate()) <= "+saleReturnDays+" or "+saleReturnDays+" = 0) "
+ " and exists(select 1 from tSalesOrderSubDtl where sSubOrderID = a.sSubOrderID and (nSendQty - isnull(nReturnQty,0)) > 0) ";
}else if (refundStatus == 2) { /*查询指定状态订单:2=平台确认*/
sql += " and a.sSalesOrderTypeID = '2' "
+ " and isnull(a.sOldSubOrderID,'') <> '' "
+ " and a.nOrderStatus&4=0 " ;
}else if (refundStatus == 3) {
sql += " and a.sSalesOrderTypeID = '2' "
+ " and isnull(a.sOldSubOrderID,'') <> '' "
+ " and a.nOrderStatus&1=0 "
+ " and a.nOrderStatus&16=0 " ;
}else {
sql += " and a.sSalesOrderTypeID = '2' "
+ " and isnull(a.sOldSubOrderID,'') <> '' "
+ " and a.nOrderStatus&1=0 "
+ " and a.nOrderStatus&16=16 ";
}
}
String sql = "select " + " SalesOrderID = a.sSalesOrderID, " + " SubOrderID = a.sSubOrderID, "
+ " OrderDate = a.dOrderDate, " + " SalesOrderTypeID = a.sSalesOrderTypeID,"
+ " SalesOrderType = a.sSalesOrderType," + " TotalSaleQty = a.nTotalSaleQty,"
+ " TotalSaleAmount = a.nTotalSaleAmount," + " TotalDisAmount = a.nTotalDisAmount,"
+ " DeliveryTypeID = a.sDeliveryTypeID," + " DeliveryType = a.sDeliveryType,"
+ " Contacts = a.sContacts," + " Mobile = a.sMobile," + " Address = a.sAddress,"
+ " ExpressFee = a.nExpressFee," + " OrderStatus = a.nOrderStatus,"
+ " OrderStatusName = a.nOrderStatusName," + " OrderMemo = a.sOrderMemo" + " from tSalesOrderSub a "
+ " where a.sShopNO = '" + shopNo + "' ";
if (refundStatus == 1) { /* 查询指定状态订单:1=申请售后 */
sql += " and a.sSalesOrderTypeID = '0' " + " and a.sB2BOrderTypeID = '1' " + " and a.nOrderStatus&1 = 0 "
+ " and (a.nOrderStatus&16=16 or nOrderStatus&4=0) "
+ " and (datediff(dd, a.dOrderDate, getdate()) <= " + saleReturnDays + " or " + saleReturnDays
+ " = 0) "
+ " and exists(select 1 from tSalesOrderSubDtl where sSubOrderID = a.sSubOrderID and (nSendQty - isnull(nReturnQty,0)) > 0) ";
} else if (refundStatus == 2) { /* 查询指定状态订单:2=平台确认 */
sql += " and a.sSalesOrderTypeID = '2' " + " and isnull(a.sOldSubOrderID,'') <> '' "
+ " and a.nOrderStatus&4=0 ";
} else if (refundStatus == 3) {
sql += " and a.sSalesOrderTypeID = '2' " + " and isnull(a.sOldSubOrderID,'') <> '' "
+ " and a.nOrderStatus&1=0 " + " and a.nOrderStatus&16=0 ";
} else {
sql += " and a.sSalesOrderTypeID = '2' " + " and isnull(a.sOldSubOrderID,'') <> '' "
+ " and a.nOrderStatus&1=0 " + " and a.nOrderStatus&16=16 ";
}
List<Map<String, Object>> orderList = jdbcTemplate.limit(sql, page);
sortList.addAll(orderList);
sortList.sort(new Comparator<Map<String, Object>>() {
public int compare(Map<String, Object> arg0, Map<String, Object> arg1) {
Date time1 = this.getOrderTime(arg0);
Date time2 = this.getOrderTime(arg1);
return time2.compareTo(time1);
}
private Date getOrderTime(Map<String, Object> map) {
String SalesOrderTypeID = (String)map.get("SalesOrderTypeID");
if(StringUtil.isNotBlank(SalesOrderTypeID)) {
return (Date)map.get("OrderDate");
String SalesOrderTypeID = (String) map.get("SalesOrderTypeID");
if (StringUtil.isNotBlank(SalesOrderTypeID)) {
return (Date) map.get("OrderDate");
} else {
return (Date)map.get("OrderDateTime");
return (Date) map.get("OrderDateTime");
}
}
});
/*Integer start = page.getFirstRowNumber().intValue() - 1;
Integer end = page.getLastRowNumber().intValue();
Integer size = sortList.size();
end = size < end ? size : end;
page.setTotal((long)sortList.size());
List<Map<String, Object>> datas = sortList.subList(start, end);*/
if(orderList != null && orderList.size() >0 ) {
List<String> orderIdList = orderList.stream().map(o -> (String)o.get("SubOrderID")).collect(Collectors.toList());
String detailSql = "select" +
" SalesOrderID = a.sSalesOrderID," +
" SubOrderID = a.sSubOrderID," +
" Idx = a.nIdx," +
" GoodsID = a.nGoodsID," +
" GoodsNO = ag.sGoodsNO," +
" GoodsDesc = a.sGoodsDesc," +
" Spec = ag.sSpec," +
" Unit = a.sUnit," +
" SaleQty = case when b.sSalesOrderTypeID = '0' then a.nSaleQty else 0 end," +
" SalePrice = a.nSalePrice," +
" RealSalePrice = ag.nRealSalePrice," +
" SaleAmount = case when b.sSalesOrderTypeID = '0' then a.nSaleAmount else 0 end," +
" DisAmount = case when b.sSalesOrderTypeID = '0' then a.nDisAmount else 0 end," +
" PromoSalePrice = CONVERT(NUMERIC(12,2),ROUND((a.nSaleAmount)/a.nSaleQty,2))," +
" OriginaSaleAmount = a.nSaleAmount+a.nDisAmount," +
" ISGift = a.nTag&1," +
" PromoPaperNO = a.sPromoPaperNO," +
" PromoActionTypeID = a.sPromoActionTypeID," +
" ReturnQty = case when b.sSalesOrderTypeID = '0' then isnull(a.nReturnQty,0) else abs(a.nSendQty) end," +
" LeftRefundQty = case when b.sSalesOrderTypeID = '0' then a.nSendQty - isnull(a.nReturnQty,0) else 0 end," +
" Memo = a.sMemo," +
" Tag = a.nTag," +
" GoodsURL = gp.sURL "
/*
* Integer start = page.getFirstRowNumber().intValue() - 1; Integer end =
* page.getLastRowNumber().intValue(); Integer size = sortList.size(); end =
* size < end ? size : end; page.setTotal((long)sortList.size());
* List<Map<String, Object>> datas = sortList.subList(start, end);
*/
if (orderList != null && orderList.size() > 0) {
List<String> orderIdList = orderList.stream().map(o -> (String) o.get("SubOrderID"))
.collect(Collectors.toList());
String detailSql = "select" + " SalesOrderID = a.sSalesOrderID,"
+ " SubOrderID = a.sSubOrderID," + " Idx = a.nIdx,"
+ " GoodsID = a.nGoodsID," + " GoodsNO = ag.sGoodsNO,"
+ " GoodsDesc = a.sGoodsDesc," + " Spec = ag.sSpec,"
+ " Unit = a.sUnit,"
+ " SaleQty = case when b.sSalesOrderTypeID = '0' then a.nSaleQty else 0 end,"
+ " SalePrice = a.nSalePrice," + " RealSalePrice = ag.nRealSalePrice,"
+ " SaleAmount = case when b.sSalesOrderTypeID = '0' then a.nSaleAmount else 0 end,"
+ " DisAmount = case when b.sSalesOrderTypeID = '0' then a.nDisAmount else 0 end,"
+ " PromoSalePrice = CONVERT(NUMERIC(12,2),ROUND((a.nSaleAmount)/a.nSaleQty,2)),"
+ " OriginaSaleAmount = a.nSaleAmount+a.nDisAmount," + " ISGift = a.nTag&1,"
+ " PromoPaperNO = a.sPromoPaperNO," + " PromoActionTypeID = a.sPromoActionTypeID,"
+ " ReturnQty = case when b.sSalesOrderTypeID = '0' then isnull(a.nReturnQty,0) else abs(a.nSendQty) end,"
+ " LeftRefundQty = case when b.sSalesOrderTypeID = '0' then a.nSendQty - isnull(a.nReturnQty,0) else 0 end,"
+ " Memo = a.sMemo," + " Tag = a.nTag,"
+ " GoodsURL = gp.sURL "
+ " from tSalesOrderSubDtl a join tSalesOrderSub b on a.sSubOrderID = b.sSubOrderID left join tAgentContractGoods ag on a.nAgentID = ag.nAgentID "
+ " and a.sAgentContractNO = ag.sAgentContractNO and a.nGoodsID = ag.nGoodsID "
+ " left join V_GetminAgentGoodsPic gp on a.nAgentID = gp.nAgentID and a.nGoodsID = gp.nGoodsID "
+ " where a.sSubOrderID in (" + StringUtil.join("', '", "'", "'", orderIdList) + ") " +
" order by a.nIdx" ;
+ " where a.sSubOrderID in (" + StringUtil.join("', '", "'", "'", orderIdList) + ") "
+ " order by a.nIdx";
List<Map<String, Object>> goodsList = jdbcTemplate.queryForList(detailSql);
Map<String, List<Map<String, Object>>> gmList = Util.listToML(goodsList, "SubOrderID");
for(Map<String, Object> orderMap : orderList) {
for (Map<String, Object> orderMap : orderList) {
orderMap.put("SalesOrderDtl", gmList.get(orderMap.get("SubOrderID")));
}
}
......@@ -1142,92 +1057,106 @@ public class OrderServiceImpl implements OrderService {
result.put("SalesOrderList", orderList);
return new RespObject(result);
}
//提交补款记录
public List<Map<String, Object>> createSalesOrderDebtPay(String shopNO, String salesOrderID,String subOrderID,String payTypeID,String payType,String payAmount,String payCardNO) {
// 提交补款记录
public List<Map<String, Object>> createSalesOrderDebtPay(String shopNO, String salesOrderID, String subOrderID,
String payTypeID, String payType, String payAmount, String payCardNO) {
List<Map<String, Object>> returnMap = new ArrayList<Map<String, Object>>();
try {
String sql = "exec up_CreateSalesOrderDebtPay '"+shopNO+"' ,'"+salesOrderID+"' , '"+subOrderID+"' , '"+payTypeID+"' , '"+payType+"' , '"+payAmount+"' , '"+payCardNO+"' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
return returnMap;
String sql = "exec up_CreateSalesOrderDebtPay '" + shopNO + "' ,'" + salesOrderID + "' , '" + subOrderID
+ "' , '" + payTypeID + "' , '" + payType + "' , '" + payAmount + "' , '" + payCardNO + "' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
return returnMap;
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace();
}
return returnMap;
}
//回调标记已补款
// 回调标记已补款
public List<Map<String, Object>> payCallback(WxPayResponse postData) {
List<Map<String, Object>> returnMap = new ArrayList<Map<String, Object>>();
try {
String OutTradeNO = postData.getOut_trade_no();
String TransactionID = postData.getTransaction_id();
String PayCardNO = postData.getOpenid();
String PayAmount= postData.getTotal_fee().toString();
String PayDate = postData.getTime_end();
String PayAmount = postData.getTotal_fee().toString();
String PayDate = postData.getTime_end();
String PayChannel = postData.getPay_type();
String OpenID = postData.getOpenid();
String paydate = DateUtil.format(DateUtil.parse(PayDate,DateUtil.FMT_YYYYMMddHHMMSS),DateUtil.FMT_DATE_SECOND);
logger.info("支付回调单号: {}",OutTradeNO);
/*//补款后缀是_D,结算单后缀是_S
if(OutTradeNO.contains("_D")) {
String sql = "exec up_B2BSalesOrderDebtPayCallBack '"+OutTradeNO+"' ,'"+TransactionID+"' , '"+PayCardNO+"' , '"+PayAmount+"' , '"+paydate+"' , '"+PayChannel+"' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
}else if (OutTradeNO.contains("_S")) {
String sql = "exec up_CreateSettlePayCallBack '"+OutTradeNO+"' ,'"+TransactionID+"' , '"+PayCardNO+"' , '"+PayAmount+"' , '"+paydate+"' , '"+PayChannel+"' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
}else {//普通订单
String[] ary = OutTradeNO.split("_", 2);
returnMap = this.paySuccess(ary[0], new BigDecimal(PayAmount), OpenID, TransactionID, OutTradeNO, DateUtil.parse(paydate, DateUtil.FMT_DATE_SECOND));
}*/
String paydate = DateUtil.format(DateUtil.parse(PayDate, DateUtil.FMT_YYYYMMddHHMMSS),
DateUtil.FMT_DATE_SECOND);
logger.info("支付回调单号: {}", OutTradeNO);
/*
* //补款后缀是_D,结算单后缀是_S if(OutTradeNO.contains("_D")) { String sql =
* "exec up_B2BSalesOrderDebtPayCallBack '"+OutTradeNO+"' ,'"
* +TransactionID+"' , '"+PayCardNO+"' , '"+PayAmount+"' , '"+paydate+"' , '"
* +PayChannel+"' "; returnMap =
* jdbcTemplate.executeMutil(sql).getDatas().get(0); }else if
* (OutTradeNO.contains("_S")) { String sql =
* "exec up_CreateSettlePayCallBack '"+OutTradeNO+"' ,'"+TransactionID+"' , '"
* +PayCardNO+"' , '"+PayAmount+"' , '"+paydate+"' , '"+PayChannel+"' ";
* returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0); }else {//普通订单
* String[] ary = OutTradeNO.split("_", 2); returnMap = this.paySuccess(ary[0],
* new BigDecimal(PayAmount), OpenID, TransactionID, OutTradeNO,
* DateUtil.parse(paydate, DateUtil.FMT_DATE_SECOND)); }
*/
returnMap = this.doCallBack(OutTradeNO, TransactionID, PayCardNO, PayAmount, paydate, PayChannel, OpenID);
} catch (Exception e) {
logger.info("支付回调异常 ,{} ",e.getMessage());
logger.info("支付回调异常 ,{} ", e.getMessage());
}
return returnMap;
}
/**
* 微企付的回调 PayTypeID=140
* <p>Title: </p>
* <p>Description: </p>
* @param req
* @return
* 微企付的回调 PayTypeID=140
* <p>
* Title:
* </p>
* <p>
* Description:
* </p>
*
* @param req
* @return
*/
public List<Map<String, Object>> mePayCallback(String req){
String PayTypeID = "140"; //微企付
public List<Map<String, Object>> mePayCallback(String req) {
String PayTypeID = "140"; // 微企付
List<Map<String, Object>> returnMap = new ArrayList<Map<String, Object>>();
JSONObject reqObj = JSONObject.parseObject(req);
if(reqObj.containsKey("callback_from")) { //mp支付预下单 自已定的回调,非微企付官方回调
if (reqObj.containsKey("callback_from")) { // mp支付预下单 自已定的回调,非微企付官方回调
String paymentId = reqObj.getString("paymentId");
String outPaymentId = reqObj.getString("outPaymentId");
//String payStatus = reqObj.getString("payStatus");
// String payStatus = reqObj.getString("payStatus");
String PayCardNO = reqObj.getString("PayCardNO");
String PayAmount = reqObj.getString("PayAmount");
String sql = "exec up_B2BSalesOrderPayUpdate '"+outPaymentId+"' ,'"+paymentId+"' , '"+PayCardNO+"' , '"+PayAmount+"' , '"+PayTypeID+"' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
}else {
//https://businesspay.qq.com/p/doc/mse/api/server.html#%E6%94%AF%E4%BB%98%E7%BB%93%E6%9E%9C%E9%80%9A%E7%9F%A5-2
//https://businesspay.qq.com/p/doc/mse/api/server.html#%E9%80%80%E6%AC%BE%E7%BB%93%E6%9E%9C%E9%80%9A%E7%9F%A5
//mse_payment.succeeded 支付成功
//mse_payment.close 支付关单
String sql = "exec up_B2BSalesOrderPayUpdate '" + outPaymentId + "' ,'" + paymentId + "' , '" + PayCardNO
+ "' , '" + PayAmount + "' , '" + PayTypeID + "' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
} else {
// https://businesspay.qq.com/p/doc/mse/api/server.html#%E6%94%AF%E4%BB%98%E7%BB%93%E6%9E%9C%E9%80%9A%E7%9F%A5-2
// https://businesspay.qq.com/p/doc/mse/api/server.html#%E9%80%80%E6%AC%BE%E7%BB%93%E6%9E%9C%E9%80%9A%E7%9F%A5
// mse_payment.succeeded 支付成功
// mse_payment.close 支付关单
// mse_payment.revoke 支付退票
String event_type = reqObj.getString("event_type"); //
JSONObject event_content = reqObj.getJSONObject("event_content");
String payment_id = event_content.getString("payment_id"); //微企付支付单号
String out_payment_id = event_content.getString("out_payment_id"); //付款方 ID
if(event_type.equals("mse_payment.succeeded") || event_type.equals("mse_payment.close") || event_type.equals("mse_payment.revoke")) {
//String openid = event_content.getString("purchaser_id");//个人付款时对应微企付用户openid
String payment_id = event_content.getString("payment_id"); // 微企付支付单号
String out_payment_id = event_content.getString("out_payment_id"); // 付款方 ID
if (event_type.equals("mse_payment.succeeded") || event_type.equals("mse_payment.close")
|| event_type.equals("mse_payment.revoke")) {
// String openid = event_content.getString("purchaser_id");//个人付款时对应微企付用户openid
String status = event_content.getString("status");
String PayAmount = event_content.getString("amount");
String pay_succ_time = status.equals("SUCCEEDED")?event_content.getString("pay_succ_time"):"";
String StatusID ="";
String StatusName ="";
String pay_succ_time = status.equals("SUCCEEDED") ? event_content.getString("pay_succ_time") : "";
String StatusID = "";
String StatusName = "";
switch (status) {
case "SUCCEEDED":
StatusID = "1";
......@@ -1244,68 +1173,110 @@ public class OrderServiceImpl implements OrderService {
default:
break;
}
String sql = "exec up_B2BSalesOrderPayCallBack '"+out_payment_id+"' ,'"+payment_id+"' , '"+PayAmount+"' , '"+pay_succ_time+"' , '"+PayTypeID+"' , '"+StatusID+"' , '"+StatusName+"' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
}else if (event_type.equals("mse_refund.succeeded")) { //退款成功
//up_B2BCancelOrderBizPayCallBack
String sql = "exec up_B2BSalesOrderPayCallBack '" + out_payment_id + "' ,'" + payment_id + "' , '"
+ PayAmount + "' , '" + pay_succ_time + "' , '" + PayTypeID + "' , '" + StatusID + "' , '"
+ StatusName + "' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
} else if (event_type.equals("mse_refund.succeeded")) { // 退款成功
// up_B2BCancelOrderBizPayCallBack
String status = event_content.getString("status");
if(status.equals("SUCCEEDED")) {//退款成功
if (status.equals("SUCCEEDED")) {// 退款成功
String refund_id = event_content.getString("refund_id");
String succeeded_time = event_content.getString("succeeded_time").replace("T"," ").replace("+08:00", ""); //东八区时间 如:2021-06-08T10:34:56+08:00,status=SUCCEEDED时返回
String refund_amount = event_content.getString("refund_amount"); //退款金额
String sql = "exec up_B2BCancelOrderBizPayCallBack '"+out_payment_id+"' ,'"+payment_id+"','"+refund_id+"' , '"+refund_amount+"' , '"+succeeded_time+"' , '"+PayTypeID+"' , '0' , '退款成功' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
}else {
logger.info("微企付退款回调-退款状态不成功 ,{} ",req);
String succeeded_time = event_content.getString("succeeded_time").replace("T", " ")
.replace("+08:00", ""); // 东八区时间 如:2021-06-08T10:34:56+08:00,status=SUCCEEDED时返回
String refund_amount = event_content.getString("refund_amount"); // 退款金额
String sql = "exec up_B2BCancelOrderBizPayCallBack '" + out_payment_id + "' ,'" + payment_id + "','"
+ refund_id + "' , '" + refund_amount + "' , '" + succeeded_time + "' , '" + PayTypeID
+ "' , '0' , '退款成功' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
} else {
logger.info("微企付退款回调-退款状态不成功 ,{} ", req);
}
}
}
}
return returnMap;
}
public List<Map<String, Object>> doCallBack(String OutTradeNO,String TransactionID,String PayCardNO,String PayAmount,String paydate,String PayChannel,String OpenID){
// 网商银行回调
public List<Map<String, Object>> meBankCallback(String req) {
String PayTypeID = "150"; // 网商银行
List<Map<String, Object>> returnMap = new ArrayList<Map<String, Object>>();
//补款后缀是_D,结算单后缀是_S
if(OutTradeNO.contains("_D")) {
String sql = "exec up_B2BSalesOrderDebtPayCallBack '"+OutTradeNO+"' ,'"+TransactionID+"' , '"+PayCardNO+"' , '"+PayAmount+"' , '"+paydate+"' , '"+PayChannel+"' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
}else if (OutTradeNO.contains("_S")) {
String sql = "exec up_CreateSettlePayCallBack '"+OutTradeNO+"' ,'"+TransactionID+"' , '"+PayCardNO+"' , '"+PayAmount+"' , '"+paydate+"' , '"+PayChannel+"' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
}else {//普通订单
JSONObject reqObj = JSONObject.parseObject(req);
String from_type = reqObj.getString("from_type"); // PAY为支付回调、REFUND为退款回调
boolean isValid = reqObj.getBooleanValue("isValid");
if (isValid) {
if (from_type.equals("PAY")) {
String OutTradeNo = reqObj.getString("OutTradeNo");
String OrderNo = reqObj.getString("OrderNo"); // 网商订单号
String TotalAmount = reqObj.getString("TotalAmount"); //
String pay_succ_time = "";
String sql = "exec up_B2BSalesOrderPayCallBack '" + OutTradeNo + "' ,'" + OrderNo + "' , '"
+ TotalAmount + "' , '" + pay_succ_time + "' , '" + PayTypeID + "' , '1' , '支付成功' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
}
if (from_type.equals("REFUND")) {
String OutRefundNo = reqObj.getString("OutRefundNo"); // 退款交易号
String RelateOrderNo = reqObj.getString("RelateOrderNo"); // 关联网商订单号
String RefundOrderNo = reqObj.getString("RefundOrderNo"); // 退款网商订单号
String succeeded_time = DateUtil.format(
DateUtil.parse(reqObj.getString("RefundFinishDate"), DateUtil.FMT_YYYYMMddHHMMSS),
DateUtil.FMT_DATE_SECOND); // YYYYMMDDhhmmss
String RefundAmount = reqObj.getString("RefundAmount"); // 退款金额。币种同原 交易
String sql = "exec up_B2BCancelOrderBizPayCallBack '" + OutRefundNo + "' ,'" + RelateOrderNo + "','"
+ RefundOrderNo + "' , '" + RefundAmount + "' , '" + succeeded_time + "' , '" + PayTypeID
+ "' , '0' , '退款成功' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
}
}
return returnMap;
}
public List<Map<String, Object>> doCallBack(String OutTradeNO, String TransactionID, String PayCardNO,
String PayAmount, String paydate, String PayChannel, String OpenID) {
List<Map<String, Object>> returnMap = new ArrayList<Map<String, Object>>();
// 补款后缀是_D,结算单后缀是_S
if (OutTradeNO.contains("_D")) {
String sql = "exec up_B2BSalesOrderDebtPayCallBack '" + OutTradeNO + "' ,'" + TransactionID + "' , '"
+ PayCardNO + "' , '" + PayAmount + "' , '" + paydate + "' , '" + PayChannel + "' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
} else if (OutTradeNO.contains("_S")) {
String sql = "exec up_CreateSettlePayCallBack '" + OutTradeNO + "' ,'" + TransactionID + "' , '" + PayCardNO
+ "' , '" + PayAmount + "' , '" + paydate + "' , '" + PayChannel + "' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
} else {// 普通订单
String[] ary = OutTradeNO.split("_", 2);
returnMap = this.paySuccess(ary[0], new BigDecimal(PayAmount), OpenID, TransactionID, OutTradeNO, DateUtil.parse(paydate, DateUtil.FMT_DATE_SECOND));
returnMap = this.paySuccess(ary[0], new BigDecimal(PayAmount), OpenID, TransactionID, OutTradeNO,
DateUtil.parse(paydate, DateUtil.FMT_DATE_SECOND));
}
return returnMap;
}
//提交结算付款记录
// 提交结算付款记录
@Override
public List<Map<String, Object>> createSettlePay(String settleNO, String payTypeID, String payType,
String payAmount, String payCardNO) {
List<Map<String, Object>> returnMap = new ArrayList<Map<String, Object>>();
try {
String sql = "exec up_CreateSettlePay '"+settleNO+"' , '"+payTypeID+"' , '"+payType+"' , '"+payAmount+"' , '"+payCardNO+"' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
return returnMap;
String sql = "exec up_CreateSettlePay '" + settleNO + "' , '" + payTypeID + "' , '" + payType + "' , '"
+ payAmount + "' , '" + payCardNO + "' ";
returnMap = jdbcTemplate.executeMutil(sql).getDatas().get(0);
return returnMap;
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace();
}
return returnMap;
}
public static void main(String[] args) {
String s = "2021-06-08T10:34:56+08:00".replace("T"," ").replace("+08:00", "");
System.out.println(s);
String aa = "20230421121212";
String a1 = DateUtil.format(DateUtil.parse(aa, DateUtil.FMT_YYYYMMddHHMMSS), DateUtil.FMT_DATE_SECOND);
System.out.println(a1);
}
}
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