package com.yc.sdk.shopping.action;
|
|
import java.text.DecimalFormat;
|
import java.text.SimpleDateFormat;
|
import java.util.List;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpSession;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.context.annotation.Scope;
|
import org.springframework.dao.DataAccessException;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import com.google.gson.JsonArray;
|
import com.google.gson.JsonObject;
|
import com.yc.action.BaseAction;
|
import com.yc.entity.DataSourceEntity;
|
import com.yc.multiData.MultiDataSource;
|
import com.yc.multiData.SpObserver;
|
import com.yc.sdk.shopping.action.api.ShopCcCode;
|
import com.yc.sdk.shopping.entity.CurrencyEntity;
|
import com.yc.sdk.shopping.entity.CustomerEntity;
|
import com.yc.sdk.shopping.entity.GroupBuyingEntity;
|
import com.yc.sdk.shopping.entity.OrderDetailEntity;
|
import com.yc.sdk.shopping.entity.OrderEntity;
|
import com.yc.sdk.shopping.entity.SettingEntity;
|
import com.yc.sdk.shopping.entity.ShopCcCodeEntity;
|
import com.yc.sdk.shopping.service.CartIfc;
|
import com.yc.sdk.shopping.service.CurrencyIfc;
|
import com.yc.sdk.shopping.service.SettingIfc;
|
import com.yc.sdk.shopping.service.imagedata.ShoppingImageDataIfc;
|
import com.yc.sdk.shopping.service.order.OrderIfc;
|
import com.yc.sdk.shopping.service.register.AccountIfc;
|
import com.yc.sdk.shopping.util.SettingKey;
|
import com.yc.sdk.shopping.util.StringReplaceUtil;
|
import com.yc.utils.SessionKey;
|
|
@Controller
|
@Scope("prototype")
|
public class Order extends BaseAction{
|
@Autowired
|
OrderIfc orderIfc;
|
|
@Autowired
|
SettingIfc settingIfc ;
|
@Autowired
|
CartIfc cartIfc;
|
@Autowired
|
ShoppingImageDataIfc imgData ;
|
@Autowired
|
AccountIfc accountIfc ;
|
@Autowired
|
CurrencyIfc currencyIfc;
|
|
/**
|
* 修改单据状态,客户删单,单据对客户隐藏
|
*
|
* @param request
|
* @param response
|
*/
|
@RequestMapping("/shopping/orderDelete.do")
|
public void orderDelete(HttpServletRequest request,
|
HttpServletResponse response) {
|
HttpSession session = request.getSession();
|
JsonObject json = new JsonObject();
|
JsonObject errJson = new JsonObject();
|
String docCode=request.getParameter(SettingKey.DOCCODE)==null?"":request.getParameter(SettingKey.DOCCODE);
|
String cltCode = (session.getAttribute(SettingKey.CLTCODE)==null?"":(String)session.getAttribute(SettingKey.CLTCODE));
|
String hostUrl = SettingKey.getHostUrl(request);
|
// 将微信corpid组装成url
|
String wxQueryString = SettingKey.getQueryStringByWx(request);
|
boolean isMoblieBrowser = SettingKey.isMoblieBrowser(request);
|
//String dbId = (String) session.getAttribute(SessionKey.SHOPPING_DBID);
|
try {
|
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ;
|
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源
|
|
|
Boolean issuccess = orderIfc.deleteSalesOrder(cltCode,docCode);
|
if (!issuccess) {
|
json.addProperty("success", "删除订单失败!");
|
json.addProperty("state", issuccess ? "success": "falied");
|
this.printJson(response, json.toString());
|
return;
|
}
|
json.addProperty("state", issuccess ? "success": "falied");
|
json.addProperty("success", "删除订单成功!");
|
String redirect = hostUrl
|
+ "/shopping/"
|
+ (isMoblieBrowser ? "mobile/" : "")
|
+ "account/order.jsp?"+ SettingKey.DOCCODE + "="
|
+ docCode
|
+ ""
|
+ (wxQueryString == null || "".equals(wxQueryString) ? ""
|
: "&" + wxQueryString);
|
json.addProperty("redirect", redirect);
|
this.printJson(response, json.toString());
|
return;
|
} catch (DataAccessException e) {
|
|
e.printStackTrace();
|
errJson.addProperty("warning", e.getCause() != null ?e.getCause().getMessage():e.getMessage());
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
} catch (Exception e) {
|
e.printStackTrace();
|
errJson.addProperty("warning", e.getCause() != null ?e.getCause().getMessage():e.getMessage());
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
@RequestMapping("/shopping/orderlist.do")
|
public void getOrderList(HttpServletRequest request,HttpServletResponse response) {
|
HttpSession session=request.getSession();
|
//String dbId = (String) session.getAttribute(SessionKey.SHOPPING_DBID);
|
String cltCode = (session.getAttribute(SettingKey.CLTCODE)==null?"":(String)session.getAttribute(SettingKey.CLTCODE));
|
String userCode = (session.getAttribute(SessionKey.USERCODE) == null ? ""
|
: (String)session.getAttribute(SessionKey.USERCODE));
|
|
//String isShowOnlyApproving = request.getParameter("isShowOnlyApproving") ; //是否只显示导购称重审核的订单
|
String isAllowPayable = request.getParameter("isAllowPayable") ; //是否可支付:0 不能支付(只显示导购称重审核的订单),1可支付(只显示待客户支付的订单),2已支付
|
|
//是否导购
|
boolean isShopGuide = (session.getAttribute(SettingKey.isShopGuide)!=null ? (boolean)session.getAttribute(SettingKey.isShopGuide) :false );
|
|
|
//将微信corpid组装成url
|
//String wxQueryString = SettingKey.getQueryStringByWx(request);
|
//boolean isMoblieBrowser = SettingKey.isMoblieBrowser(request);
|
String hostUrl = SettingKey.getHostUrl(request) ;
|
|
JsonObject json = new JsonObject();
|
JsonObject errJson = new JsonObject();
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd") ;
|
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") ;
|
SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm") ;
|
DecimalFormat df = new DecimalFormat("0.00");
|
try {
|
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ;
|
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源
|
SettingEntity settingEntity = settingIfc.getSettingEntity() ;
|
// 取网店 shopcccode
|
ShopCcCodeEntity shopCcCodeEntity = ShopCcCode.getShopCcCode(settingEntity,request);
|
//货币
|
CurrencyEntity currencyEntity = currencyIfc.getUserCurrency(userCode);
|
|
//检查该客户是否存在
|
if (cltCode != null && !"".equals(cltCode)) {
|
|
CustomerEntity customerEntity = accountIfc.getLoginInfoByCltCode(cltCode,cltCode,cltCode);
|
if (customerEntity==null || customerEntity.getCltCode()==null||customerEntity.getCltCode().equals("")) {
|
cltCode = null;
|
session.removeAttribute(SettingKey.CLTCODE);
|
}
|
}
|
|
if (cltCode == null || "".equals(cltCode) ) {
|
json.addProperty(SettingKey.CLTCODE,"");
|
return ;
|
}else {
|
json.addProperty(SettingKey.CLTCODE,cltCode);
|
}
|
|
|
//所有订单头信息
|
List<OrderEntity> orderList = null;
|
if (isAllowPayable != null && !isAllowPayable.equals("")) {
|
orderList = orderIfc.getOrderListByIsAllowPayable(cltCode,Integer.parseInt(isAllowPayable) ,shopCcCodeEntity.getShopCcCode()) ; //待称重订单列表
|
} else {
|
orderList = orderIfc.getOrderList( cltCode,shopCcCodeEntity.getShopCcCode()) ; //所有订单列表
|
}
|
|
JsonArray orderListJsonArray = new JsonArray();
|
for(int k = 0 ;orderList != null&&orderList.size()>0&& k < orderList.size();k++) {
|
OrderEntity orderEntity = orderList.get(k) ;
|
JsonObject orderEntityJsonObject = new JsonObject();
|
//status : 0 所有,1.待付款,2.待收货,3.已完成,4.已取消
|
String groupBy = "所有" ;
|
if (orderEntity.getDocStatus()!=null&&orderEntity.getDocStatus().equals(0)) {
|
groupBy = "待付款";
|
}
|
|
if (orderList.get(k).getDocStatus().equals(100) && orderEntity.getFaHuoStatus()!=null&&!orderEntity.getFaHuoStatus().equals("")) {
|
groupBy = "待收货";
|
}
|
|
if (orderList.get(k).getDocStatus().equals(100) && orderList.get(k).isReceiptGoodsByCustomer()) {
|
groupBy = "已完成";
|
}
|
if (orderList.get(k).getDocStatus().equals(-200)) {
|
groupBy = "已取消";
|
}
|
orderEntityJsonObject.addProperty("GroupBy", groupBy);
|
|
//订单行信息
|
List<OrderDetailEntity> orderDetailList = orderIfc.getOrderDetailList(cltCode,orderEntity.getDocCode()) ;
|
if (orderDetailList ==null||orderDetailList.size() == 0) {
|
continue ;
|
}
|
orderEntityJsonObject.addProperty(SettingKey.DOCCODE, orderEntity.getDocCode());
|
orderEntityJsonObject.addProperty("FormId", orderEntity.getFormId());
|
orderEntityJsonObject.addProperty("DocType", orderEntity.getDocType()); //单据类型:微信订单 、微信团购订单
|
orderEntityJsonObject.addProperty("CcCode", orderEntity.getCcCode());
|
orderEntityJsonObject.addProperty("CcName", orderEntity.getCcName());
|
orderEntityJsonObject.addProperty("SumTotalMoney2",orderEntity.getSumTotalMoney2()); //优惠前订单总金额
|
orderEntityJsonObject.addProperty("SumTotalMoney3",orderEntity.getSumTotalMoney3()); //优惠后订单总金额 ,由 PayableAmount 代替
|
orderEntityJsonObject.addProperty("PayableAmount",orderEntity.getPayableAmount()); //优惠后订单总金额
|
orderEntityJsonObject.addProperty("ReduceMoney",orderEntity.getReduceMoney()); //优惠金额
|
orderEntityJsonObject.addProperty("TransCosts",orderEntity.getTransCosts()); //运费
|
orderEntityJsonObject.addProperty("HandlingCharges",orderEntity.getHandlingCharges()); //搬运费
|
|
orderEntityJsonObject.addProperty("Currency",orderEntity.getCurrency()); //币种
|
orderEntityJsonObject.addProperty("CurrencySign",orderEntity.getCurrencySign()); //货币符号
|
orderEntityJsonObject.addProperty("Address",orderEntity.getPropertyAddress()); //地址
|
orderEntityJsonObject.addProperty("LinkMan",orderEntity.getLinkMan() != null &&!"".equals(orderEntity.getLinkMan())?orderEntity.getLinkMan(): orderEntity.getCltName()); //联系人
|
orderEntityJsonObject.addProperty("Telephone",orderEntity.getTel()); //联系人电话
|
orderEntityJsonObject.addProperty("DeliveryMethod",orderEntity.getDeliveryMethod());
|
orderEntityJsonObject.addProperty("DeliveryDate",sdf.format(orderEntity.getDocDate()));
|
orderEntityJsonObject.addProperty("InvoiceType","电子普通发票");
|
orderEntityJsonObject.addProperty("HDMemo",orderEntity.getHdMemo());
|
|
|
orderEntityJsonObject.addProperty("LogisticsCode",orderEntity.getLogisticsCode()); //物流单号
|
orderEntityJsonObject.addProperty("ShipperCode",orderEntity.getShipperCode()); //快递公司编号
|
orderEntityJsonObject.addProperty("ShipperName",orderEntity.getShipperName()); //快递公司名称
|
orderEntityJsonObject.addProperty("isAllowPayable",orderEntity.getIsAllowPayable()); //是否可支付 isAllowPayable 状态: 0.不能支付,1.可支付,2.已支付 ,3.正在退款,4.已退款,5.无需支付
|
orderEntityJsonObject.addProperty("DocStatus",orderEntity.getDocStatus()); //单据状态
|
|
orderEntityJsonObject.addProperty("DocDate",orderEntity.getDocDate()==null?"":sdf.format(orderEntity.getDocDate()));
|
orderEntityJsonObject.addProperty("EnterDate",orderEntity.getEnterDate()==null?"":sdf2.format(orderEntity.getEnterDate()));
|
orderEntityJsonObject.addProperty("PreSendDate",orderEntity.getPreSendDate()==null?"":sdf3.format(orderEntity.getPreSendDate()));
|
orderEntityJsonObject.addProperty("PayableSecondBalance",orderEntity.getPayableSecondBalance()!=null&& orderEntity.getPayableSecondBalance().intValue() >0?orderEntity.getPayableSecondBalance():0); //下单后支付倒计时秒数
|
orderEntityJsonObject.addProperty("GroupBuyingDocCode",orderEntity.getGroupBuyingDocCode()); //团购订单号
|
orderEntityJsonObject.addProperty("GroupBuyingMembers",orderEntity.getGroupBuyingMembers()); //需要多少人成团
|
orderEntityJsonObject.addProperty("GroupBuyingHasMembers",orderEntity.getGroupBuyingHasMembers()); //已有多少人成团
|
orderEntityJsonObject.addProperty("GroupBuyingMembersBalance",orderEntity.getGroupBuyingMembersBalance()); //还差多少人成团
|
|
//获取单据状态描述
|
String docStatusDesc = null;
|
if (orderEntity.getFormId()!=null&&orderEntity.getFormId().intValue() == 120238) {
|
docStatusDesc = orderEntity.getHeXiaoStatus();
|
if (docStatusDesc==null||"".equals(docStatusDesc)) {
|
docStatusDesc = "待核销";
|
}
|
}else {
|
docStatusDesc = getDocStatusDescription(orderEntity) ;
|
}
|
|
orderEntityJsonObject.addProperty("DocStatusDesc", docStatusDesc);
|
double totalQuantity = 0 ;
|
int itemCount = 0 ;
|
JsonArray orderDetailListJsonArray = new JsonArray();
|
for (int i =0;orderDetailList != null && i < orderDetailList.size();i++) {
|
OrderDetailEntity orderDetailEntity = orderDetailList.get(i) ;
|
JsonObject orderDetailEntityJsonObject = new JsonObject();
|
//主图片
|
orderDetailEntityJsonObject.addProperty("PhotoPath",SettingKey.getUrl(hostUrl, orderDetailEntity.getPhotoPathUrl(), dataSourceEntity.getDbId()+"",null));
|
/* imgData.getImageUrl(orderDetailEntity.getPhotoPath(), settingEntity.getImageProductWidth(),
|
settingEntity.getImageProductHeight(), settingEntity.isShowProductOrgImage(),
|
settingEntity.isFromCached(), request)
|
+ (wxQueryString == null || "".equals(wxQueryString) ? "" : "?" + wxQueryString));
|
*/
|
|
if (settingEntity.isShowBrand()) {
|
orderDetailEntityJsonObject.addProperty("Brand", orderDetailEntity.getBrand());
|
}
|
if (settingEntity.isShowMatName()) {
|
orderDetailEntityJsonObject.addProperty("MatName", orderDetailEntity.getMatName());
|
}
|
orderDetailEntityJsonObject.addProperty("MatCode", orderDetailEntity.getMatCode());
|
orderDetailEntityJsonObject.addProperty("isShowMatCode", settingEntity.isShowMatCode());
|
orderDetailEntityJsonObject.addProperty("isShowMatName", settingEntity.isShowMatName());
|
orderDetailEntityJsonObject.addProperty("isShowSpecial", settingEntity.isShowSpecial());
|
orderDetailEntityJsonObject.addProperty("isShowPrice", settingEntity.isShowPrice());
|
orderDetailEntityJsonObject.addProperty("isShowPoints", settingEntity.isShowPoints());
|
orderDetailEntityJsonObject.addProperty("isShowBrand", settingEntity.isShowBrand());
|
orderDetailEntityJsonObject.addProperty("StockDisplay", settingEntity.getStockDisplay());
|
|
orderDetailEntityJsonObject.addProperty("ShopMatCode", orderDetailEntity.getShopMatCode());
|
|
if (settingEntity.isShowSpecial()) {
|
orderDetailEntityJsonObject.addProperty("Special", orderDetailEntity.getSpecial());
|
}
|
|
if (settingEntity.isStartupMatName2()) {
|
orderDetailEntityJsonObject.addProperty("MatName2Label", settingEntity.getMatName2Label());
|
orderDetailEntityJsonObject.addProperty("MatName2", orderDetailEntity.getMatName2());
|
}
|
|
if (settingEntity.isStartupMatName3()) {
|
orderDetailEntityJsonObject.addProperty("MatName3Label", settingEntity.getMatName3Label());
|
orderDetailEntityJsonObject.addProperty("MatName3", orderDetailEntity.getMatName3());
|
}
|
|
if (settingEntity.isStartupMatName4()) {
|
orderDetailEntityJsonObject.addProperty("MatName4Label", settingEntity.getMatName4Label());
|
orderDetailEntityJsonObject.addProperty("MatName4", orderDetailEntity.getMatName4());
|
}
|
|
if (orderDetailEntity.getOptionJson() !=null && !"".equals(orderDetailEntity.getOptionJson())) {
|
//Map<String,Object> lists=gson.fromJson(cartEntity.getOptionJson(),new TypeToken<Map<String,Object>>(){}.getType());
|
orderDetailEntityJsonObject.addProperty("OptionJson", orderDetailEntity.getOptionJson()) ; //gson.toJson(settingEntity));
|
}
|
|
if (settingEntity.isShowPrice()) {
|
orderDetailEntityJsonObject.addProperty("Price", orderDetailEntity.getPrice() ); // 实际价格
|
orderDetailEntityJsonObject.addProperty("Currency", currencyEntity.getCurrency());
|
orderDetailEntityJsonObject.addProperty("CurrencySign", currencyEntity.getCurrencySign());
|
}
|
|
//取出导购上传的图片
|
JsonArray orderDetailImageJsonArray = new JsonArray();
|
if (orderDetailEntity.getImages() != null && !"".equals(orderDetailEntity.getImages())) {
|
String unids[] = orderDetailEntity.getImages().split(";") ;
|
String unid = unids[0] ;
|
for (int m = 0 ;m < unids.length;m++) {
|
if (m == 0) continue ;
|
String seq = unids[m] ;
|
JsonObject unidSeqJson = new JsonObject();
|
unidSeqJson.addProperty(SettingKey.UNID,unid) ;
|
unidSeqJson.addProperty("seq",seq) ;
|
unidSeqJson.addProperty("url",imgData.getImageUrl(unid +";" + seq, settingEntity.getImageProductWidth(),
|
settingEntity.getImageProductHeight(), settingEntity.isShowProductOrgImage(),
|
settingEntity.isFromCached(), request) ) ;
|
orderDetailImageJsonArray.add(unidSeqJson) ;
|
}
|
}
|
orderDetailEntityJsonObject.add("Images",orderDetailImageJsonArray) ;
|
|
orderDetailEntityJsonObject.addProperty("Quantity", orderDetailEntity.getDigit()) ;
|
orderDetailEntityJsonObject.addProperty("RowId", orderDetailEntity.getRowId());
|
//是否显示:退货按钮
|
orderDetailEntityJsonObject.addProperty("isShowReturnButton", cltCode.equals(orderEntity.getCltCode()) && orderEntity.getDocStatus()!=null&&orderEntity.getDocStatus().equals(100)&&orderDetailEntity.getPickDigit() != 0 && (orderDetailEntity.getTuiHuoKaiDanStatusItem()==null ||"".equals(orderDetailEntity.getTuiHuoKaiDanStatusItem())) ?true:false);
|
|
orderDetailEntityJsonObject.addProperty("skuId1", orderDetailEntity.getSkuId1());
|
orderDetailEntityJsonObject.addProperty("skuName1", orderDetailEntity.getSkuName1());
|
orderDetailEntityJsonObject.addProperty("skuId2", orderDetailEntity.getSkuId2());
|
orderDetailEntityJsonObject.addProperty("skuName2", orderDetailEntity.getSkuName2());
|
orderDetailEntityJsonObject.addProperty("skuId3", orderDetailEntity.getSkuId3());
|
orderDetailEntityJsonObject.addProperty("skuName3", orderDetailEntity.getSkuName3());
|
orderDetailEntityJsonObject.addProperty("skuId4", orderDetailEntity.getSkuId4());
|
orderDetailEntityJsonObject.addProperty("skuName4", orderDetailEntity.getSkuName4());
|
orderDetailEntityJsonObject.addProperty("skuId5", orderDetailEntity.getSkuId5());
|
orderDetailEntityJsonObject.addProperty("skuName5", orderDetailEntity.getSkuName5());
|
orderDetailEntityJsonObject.addProperty("skuId6", orderDetailEntity.getSkuId6());
|
orderDetailEntityJsonObject.addProperty("skuName6", orderDetailEntity.getSkuName6());
|
orderDetailEntityJsonObject.addProperty("skuId7", orderDetailEntity.getSkuId7());
|
orderDetailEntityJsonObject.addProperty("skuName7", orderDetailEntity.getSkuName7());
|
orderDetailEntityJsonObject.addProperty("skuId8", orderDetailEntity.getSkuId8());
|
orderDetailEntityJsonObject.addProperty("skuName8", orderDetailEntity.getSkuName8());
|
orderDetailEntityJsonObject.addProperty("skuId9", orderDetailEntity.getSkuId9());
|
orderDetailEntityJsonObject.addProperty("skuName9", orderDetailEntity.getSkuName9());
|
orderDetailEntityJsonObject.addProperty("skuId10", orderDetailEntity.getSkuId10());
|
orderDetailEntityJsonObject.addProperty("skuName10", orderDetailEntity.getSkuName10());
|
|
totalQuantity += orderDetailEntity.getDigit();
|
itemCount ++ ;
|
orderDetailListJsonArray.add(orderDetailEntityJsonObject);
|
}
|
orderEntityJsonObject.addProperty("TotalQuantity",df.format(totalQuantity)); //所有商品总“数量”
|
orderEntityJsonObject.addProperty("ItemCount",itemCount); //有多少种类商品
|
orderEntityJsonObject.add("OrderDetailList", orderDetailListJsonArray);
|
|
//是否显示:支付按钮
|
orderEntityJsonObject.addProperty("isShowPayButton",cltCode.equals(orderEntity.getCltCode()) && orderEntity.getDocStatus()!=null&&orderEntity.getDocStatus().equals(0)
|
&&orderEntity.getCltCode()!=null&&orderEntity.getCltCode().equals(cltCode)
|
&&orderEntity.getIsAllowPayable()!=null&&orderEntity.getIsAllowPayable().equals(1)?true:false);
|
|
//是否显示:取消订单按钮
|
//orderEntityJsonObject.addProperty("isShowCancelButton", orderEntity.getDocStatus()!=null&&orderEntity.getDocStatus().equals(100)&&orderEntity.getIsAllowPayable()!=null&&orderEntity.getIsAllowPayable().intValue() == 2 && (orderEntity.getFaHuoStatus()==null || orderEntity.getFaHuoStatus().equals(""))?true:false);
|
orderEntityJsonObject.addProperty("isShowCancelButton",settingEntity.isAllowReturnOrder()&& cltCode.equals(orderEntity.getCltCode()) && orderEntity.getDocStatus()!=null&&(orderEntity.getDocStatus().equals(100)||orderEntity.getDocStatus().equals(0)) && (orderEntity.getFaHuoStatus()==null || orderEntity.getFaHuoStatus().equals(""))?true:false);
|
|
//是否显示:查看物流按钮
|
boolean isShowLogisticsButton = (orderEntity.getDocStatus()!=null&&orderEntity.getDocStatus().equals(100)&& orderEntity.getLogisticsCode()!=null && !orderEntity.getLogisticsCode().equals("")?true:false);
|
orderEntityJsonObject.addProperty("isShowLogisticsButton",(cltCode.equals(orderEntity.getCltCode())||isShopGuide)&&isShowLogisticsButton&&orderEntity.getShipperCode()!=null&& !orderEntity.getShipperCode().equals("") );
|
//是否显示:收货按钮
|
orderEntityJsonObject.addProperty("isShowReceiptButton", cltCode.equals(orderEntity.getCltCode()) && isShowLogisticsButton &&
|
orderEntity.getDocStatus()!=null&&orderEntity.getDocStatus().equals(100)&&!orderEntity.isReceiptGoodsByCustomer() ?true:false);
|
|
//是否显示:删除按钮
|
orderEntityJsonObject.addProperty("isShowDeleteButton", orderEntity.getDocStatus().equals(0) ||(orderEntity.getDocStatus()!=null &&orderEntity.getDocStatus().equals(-200)) ||(orderEntity.getDocStatus()!=null&&orderEntity.getDocStatus().equals(100)&&orderEntity.isReceiptGoodsByCustomer()) ?true:false);
|
//generateOrderProcess : 0.生成订单可立即支付 ,1.生成订单,导购审核后才能支付(适用于生鲜类卖家,卖牛肉牛排的 ,他们按份卖,客户下单 时1份,假设1份 500克,实际卖出时是按称重卖的,可能有 510克,那最后付款也是按 510克付。)
|
//orderEntityJsonObject.addProperty("generateOrderProcess",settingEntity.getGenerateOrderProcess() );
|
|
orderListJsonArray.add(orderEntityJsonObject);
|
}
|
|
json.add("list", orderListJsonArray);
|
this.printJson(response, json.toString());
|
|
return ;
|
}catch(DataAccessException e ) {
|
e.printStackTrace();
|
errJson.addProperty("warning", e.getCause() != null ?e.getCause().getMessage():e.getMessage());
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}catch(Exception e){
|
e.printStackTrace();
|
errJson.addProperty("warning", e.getMessage());
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}finally {
|
SpObserver.setDBtoInstance();
|
}
|
|
}
|
|
|
|
private String getDocStatusDescription(OrderEntity orderEntity) {
|
if (orderEntity.getDocStatus().equals(-200)) {
|
return "已取消";
|
}
|
|
if (orderEntity.getDocStatus().equals(0)) {
|
//是否可支付 isAllowPayable 状态: 0.不能支付,1.可支付,2.已支付 ,3.正在退款,4.已退款,5.无需支付
|
if (orderEntity.getIsAllowPayable().equals(0)) {
|
return "待卖家确认";
|
}else if (orderEntity.getIsAllowPayable().equals(1)) {
|
return "待买家付款";
|
}else if (orderEntity.getIsAllowPayable().equals(2)) {
|
return "待商家发货" ; // "买家已付款";
|
}else if (orderEntity.getIsAllowPayable().equals(3)) {
|
return "正在退款";
|
}else if (orderEntity.getIsAllowPayable().equals(4)){
|
return "已退款";
|
}else if (orderEntity.getIsAllowPayable().equals(5)){
|
return "待商家发货";
|
}
|
|
}
|
|
|
if (orderEntity.getDocStatus().equals(100)) {
|
if (orderEntity.getTuiHuoKaiDanDoccode()!=null&&!orderEntity.getTuiHuoKaiDanDoccode().equals("")) {
|
if (orderEntity.getTuiHuoRuKuDoccode() == null || "".equals(orderEntity.getTuiHuoRuKuDoccode())) {
|
return "已申请退货";
|
}else {
|
return orderEntity.getTuiHuoKaiDanStatus().replace("开单",""); //"已全部退货" ,"部分退货";
|
}
|
}
|
|
if ((orderEntity.getFaHuoStatus()!=null&&!orderEntity.getFaHuoStatus().equals(""))||orderEntity.isReceiptGoodsByCustomer() ) {
|
if (orderEntity.isReceiptGoodsByCustomer() || (orderEntity.getFaHuoLastDateDays() != null && orderEntity.getFaHuoLastDateDays().intValue() > 15)) {
|
return "交易完成"; //最后发货日期大于 15 天,则认为买家已经收货
|
}else {
|
return "卖家已发货";
|
}
|
}
|
|
if (orderEntity.getIsAllowPayable().equals(2)) {
|
return "待商家发货" ; //"买家已付款";
|
}else if (orderEntity.getIsAllowPayable().equals(3)) {
|
return "正在退款";
|
}else if (orderEntity.getIsAllowPayable().equals(4)){
|
return "已退款";
|
}else if (orderEntity.getIsAllowPayable().equals(5)){
|
return "待商家发货";
|
}
|
}
|
return "交易完成" ;
|
}
|
|
@RequestMapping("/shopping/orderdetail.do")
|
public void getOrderDetail(HttpServletRequest request,HttpServletResponse response) {
|
HttpSession session=request.getSession();
|
//String dbId = (String) session.getAttribute(SessionKey.SHOPPING_DBID);
|
String cltCode = (session.getAttribute(SettingKey.CLTCODE)==null?"":(String)session.getAttribute(SettingKey.CLTCODE));
|
String userCode = (session.getAttribute(SessionKey.USERCODE) == null ? ""
|
: (String)session.getAttribute(SessionKey.USERCODE));
|
String docCode=request.getParameter(SettingKey.DOCCODE)==null?"":request.getParameter(SettingKey.DOCCODE);
|
String formId=request.getParameter(SettingKey.FORMID)==null?"":request.getParameter(SettingKey.FORMID);
|
|
//是否导购
|
boolean isShopGuide = (session.getAttribute(SettingKey.isShopGuide)!=null ? (boolean)session.getAttribute(SettingKey.isShopGuide) :false );
|
|
//将微信corpid组装成url
|
//String wxQueryString = SettingKey.getQueryStringByWx(request);
|
//boolean isMoblieBrowser = SettingKey.isMoblieBrowser(request);
|
String hostUrl = SettingKey.getHostUrl(request) ;
|
DecimalFormat df = new DecimalFormat("0.00");
|
|
JsonObject json = new JsonObject();
|
JsonObject errJson = new JsonObject();
|
|
try {
|
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ;
|
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源
|
SettingEntity settingEntity = settingIfc.getSettingEntity() ;
|
//货币
|
CurrencyEntity currencyEntity = currencyIfc.getUserCurrency(userCode);
|
|
//检查该客户是否存在
|
if (cltCode != null && !"".equals(cltCode)) {
|
|
CustomerEntity customerEntity = accountIfc.getLoginInfoByCltCode(cltCode,cltCode,cltCode);
|
if (customerEntity==null || customerEntity.getCltCode()==null||customerEntity.getCltCode().equals("")) {
|
cltCode = null;
|
session.removeAttribute(SettingKey.CLTCODE);
|
}
|
}
|
|
if (cltCode == null || "".equals(cltCode) ) {
|
json.addProperty(SettingKey.CLTCODE,"");
|
return ;
|
}else {
|
json.addProperty(SettingKey.CLTCODE,cltCode);
|
}
|
|
|
OrderEntity orderEntity= orderIfc.getOrderHeaderEntity( cltCode,docCode,formId != null&&!"".equals(formId)?Integer.parseInt(formId):null) ;
|
if (orderEntity == null) {
|
errJson.addProperty("warning", "订单【" + docCode+"】不存在" );
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}
|
|
//获取单据状态描述
|
String docStatusDesc = null;
|
if (orderEntity.getFormId()!=null&&orderEntity.getFormId().intValue() == 120238) {
|
docStatusDesc = orderEntity.getHeXiaoStatus();
|
if (docStatusDesc==null||"".equals(docStatusDesc)) {
|
docStatusDesc = "待核销";
|
}
|
}else {
|
docStatusDesc = getDocStatusDescription(orderEntity) ;
|
}
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd") ;
|
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") ;
|
SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm") ;
|
json.addProperty("StatusDesc", docStatusDesc);
|
json.addProperty(SettingKey.DOCCODE,orderEntity.getDocCode());
|
json.addProperty("FormId", orderEntity.getFormId());
|
json.addProperty("CcCode", orderEntity.getCcCode());
|
json.addProperty("CcName", orderEntity.getCcName());
|
json.addProperty("DocDate",orderEntity.getDocDate()==null?"":sdf.format(orderEntity.getDocDate()));
|
json.addProperty("EnterDate",orderEntity.getEnterDate()==null?"":sdf2.format(orderEntity.getEnterDate()));
|
json.addProperty("PayMethod", orderEntity.getWeiXinPayAmount()!=0?"微信支付":"余额支付");
|
json.addProperty("SumTotalMoney2",orderEntity.getSumTotalMoney2()); //优惠前订单总金额
|
json.addProperty("SumTotalMoney3",orderEntity.getSumTotalMoney3()); //优惠后订单总金额 ,由 PayableAmount 代替
|
json.addProperty("PayableAmount",orderEntity.getPayableAmount()); //优惠后订单总金额
|
json.addProperty("ReduceMoney",orderEntity.getReduceMoney()); //优惠金额
|
json.addProperty("TransCosts",orderEntity.getTransCosts()); //运费
|
json.addProperty("HandlingCharges",orderEntity.getHandlingCharges()); //搬运费
|
|
json.addProperty("Currency",orderEntity.getCurrency());
|
json.addProperty("CurrencySign",orderEntity.getCurrencySign());
|
|
//客户名称、电话、地址加密
|
json.addProperty("Address",orderEntity.getCltCode().equals( cltCode)||isShopGuide?orderEntity.getPropertyAddress() : StringReplaceUtil.getStarString2(orderEntity.getPropertyAddress(),orderEntity.getPropertyAddress().length() - 10,0) );
|
String linkMan = orderEntity.getLinkMan() != null &&!"".equals(orderEntity.getLinkMan())?orderEntity.getLinkMan(): orderEntity.getCltName();
|
json.addProperty("LinkMan",orderEntity.getCltCode().equals( cltCode)||isShopGuide?linkMan : StringReplaceUtil.getStarString2(linkMan,1,0)); //联系人
|
json.addProperty("Telephone",orderEntity.getCltCode().equals( cltCode)||isShopGuide?orderEntity.getTel():StringReplaceUtil.getStarString2(orderEntity.getTel(),3,4));
|
|
json.addProperty("AddressName",orderEntity.getCltCode().equals( cltCode)||isShopGuide?orderEntity.getFullAddressName():StringReplaceUtil.getStarString2(orderEntity.getFullAddressName(),orderEntity.getFullAddressName().length() - 5,0));
|
json.addProperty("Street",orderEntity.getCltCode().equals( cltCode)||isShopGuide?orderEntity.getStreet():StringReplaceUtil.getStarString2(orderEntity.getStreet(),orderEntity.getStreet().length() - 5,0));
|
json.addProperty("FullAddress",orderEntity.getCltCode().equals( cltCode)||isShopGuide?orderEntity.getFullAddress():StringReplaceUtil.getStarString2(orderEntity.getFullAddress(),orderEntity.getFullAddress().length() - 5,0));
|
|
json.addProperty("DeliveryMethod",orderEntity.getDeliveryMethod());
|
json.addProperty("DeliveryDate",sdf.format(orderEntity.getDocDate()));
|
json.addProperty("InvoiceType","电子普通发票");
|
json.addProperty("HDMemo",orderEntity.getHdMemo());
|
json.addProperty("isAllowPayable",orderEntity.getIsAllowPayable());
|
json.addProperty("LogisticsCode",orderEntity.getLogisticsCode()); //物流单号
|
json.addProperty("LogisticsCodeState",orderEntity.getLogisticsCodeState()); //物流状态
|
json.addProperty("ShipperCode",orderEntity.getShipperCode()); //快递公司编号
|
json.addProperty("ShipperName",orderEntity.getShipperName()); //快递公司名称
|
json.addProperty("isReceiptGoodsByCustomer",orderEntity.isReceiptGoodsByCustomer()); //客户是否已经点击收货
|
json.addProperty("ReceiptGoodsTime",orderEntity.getReceiptGoodsTime()==null?"":sdf2.format(orderEntity.getReceiptGoodsTime())); //客户收货时间
|
json.addProperty("DocStatus",orderEntity.getDocStatus());
|
json.addProperty("CltCode",orderEntity.getCltCode());
|
json.addProperty("PreSendDate",orderEntity.getPreSendDate()==null?"":sdf3.format(orderEntity.getPreSendDate())); //送货时间
|
json.addProperty("PayableSecondBalance",orderEntity.getPayableSecondBalance()!=null&& orderEntity.getPayableSecondBalance().intValue() >0?orderEntity.getPayableSecondBalance():0); //下单后支付倒计时秒数
|
|
//是否显示:支付按钮
|
json.addProperty("isShowPayButton",cltCode.equals(orderEntity.getCltCode()) && orderEntity.getDocStatus()!=null&&orderEntity.getDocStatus().equals(0)
|
&&orderEntity.getCltCode()!=null&&orderEntity.getCltCode().equals(cltCode)
|
&&orderEntity.getIsAllowPayable()!=null&&orderEntity.getIsAllowPayable().equals(1)?true:false);
|
|
//是否显示:取消订单按钮
|
//json.addProperty("isShowCancelButton", orderEntity.getDocStatus()!=null&&orderEntity.getDocStatus().equals(100)&&orderEntity.getIsAllowPayable()!=null&&orderEntity.getIsAllowPayable().intValue() == 2 &&(orderEntity.getFaHuoStatus()==null || orderEntity.getFaHuoStatus().equals(""))?true:false);
|
json.addProperty("isShowCancelButton",settingEntity.isAllowReturnOrder()&&cltCode.equals(orderEntity.getCltCode()) && orderEntity.getDocStatus()!=null&&(orderEntity.getDocStatus().equals(100)||orderEntity.getDocStatus().equals(0)) && (orderEntity.getFaHuoStatus()==null || orderEntity.getFaHuoStatus().equals(""))?true:false);
|
//是否显示:查看物流按钮
|
boolean isShowLogisticsButton = (orderEntity.getDocStatus()!=null&&orderEntity.getDocStatus().equals(100)&& orderEntity.getLogisticsCode()!=null && ! orderEntity.getLogisticsCode().equals("")?true:false);
|
json.addProperty("isShowLogisticsButton",(cltCode.equals(orderEntity.getCltCode())||isShopGuide)&&isShowLogisticsButton &&orderEntity.getShipperCode()!=null&& !orderEntity.getShipperCode().equals("") );
|
|
//是否显示:收货按钮
|
json.addProperty("isShowReceiptButton", cltCode.equals(orderEntity.getCltCode()) && isShowLogisticsButton &&
|
orderEntity.getDocStatus()!=null&&orderEntity.getDocStatus().equals(100)&&!orderEntity.isReceiptGoodsByCustomer() ?true:false);
|
//是否显示:删除按钮
|
json.addProperty("isShowDeleteButton", orderEntity.getDocStatus().equals(0)||(orderEntity.getDocStatus()!=null &&orderEntity.getDocStatus().equals(-200)) || (orderEntity.getDocStatus()!=null&&orderEntity.getDocStatus().equals(100)&&orderEntity.isReceiptGoodsByCustomer()) ?true:false);
|
|
//generateOrderProcess : 0.生成订单可立即支付 ,1.生成订单,导购审核后才能支付(适用于生鲜类卖家,卖牛肉牛排的 ,他们按份卖,客户下单 时1份,假设1份 500克,实际卖出时是按称重卖的,可能有 510克,那最后付款也是按 510克付。)
|
//json.addProperty("generateOrderProcess",settingEntity.getGenerateOrderProcess() );
|
|
//分享时的状态 statusWhenSharing :1 已下单等待称重,2.已称重等待客户支付,3.客户已支付等待发货,4.已完成(包括发货、签收)
|
int statusWhenSharing = 1 ;
|
if (orderEntity.getDocStatus()!=null&&orderEntity.getDocStatus().equals(0)) {
|
//是否可支付 isAllowPayable 状态: 0.不能支付,1.可支付,2.已支付 ,3.正在退款,4.已退款,5.无需支付
|
if (orderEntity.getIsAllowPayable()!= null && orderEntity.getIsAllowPayable().intValue() == 0 ) {
|
statusWhenSharing = 1;
|
} else if ( orderEntity.getIsAllowPayable()!= null && orderEntity.getIsAllowPayable().intValue() == 1) {
|
statusWhenSharing = 2 ;
|
} else {
|
statusWhenSharing = 3 ;
|
}
|
}
|
|
if (orderEntity.getDocStatus()!=null&&orderEntity.getDocStatus().equals(100)) {
|
if (orderEntity.getFaHuoStatus() == null || "".equals(orderEntity.getFaHuoStatus())) {
|
statusWhenSharing = 3 ;
|
}else {
|
statusWhenSharing = 4 ;
|
}
|
}
|
|
json.addProperty("StatusWhenSharing", statusWhenSharing);
|
|
double totalQuantity = 0 ;
|
int itemCount = 0 ;
|
List<OrderDetailEntity> orderDetailList = orderIfc.getOrderDetailList(cltCode,docCode) ;
|
JsonArray orderDetailListJsonArray = new JsonArray();
|
for (int i =0;orderDetailList != null && i < orderDetailList.size();i++) {
|
OrderDetailEntity orderDetailEntity = orderDetailList.get(i) ;
|
JsonObject orderDetailEntityJsonObject = new JsonObject();
|
//主图片
|
orderDetailEntityJsonObject.addProperty("PhotoPath",SettingKey.getUrl(hostUrl, orderDetailEntity.getPhotoPathUrl(), dataSourceEntity.getDbId()+"",null));
|
/* imgData.getImageUrl(orderDetailEntity.getPhotoPath(), settingEntity.getImageProductWidth(),
|
settingEntity.getImageProductHeight(), settingEntity.isShowProductOrgImage(),
|
settingEntity.isFromCached(), request)
|
+ (wxQueryString == null || "".equals(wxQueryString) ? "" : "?" + wxQueryString));
|
*/
|
|
if (settingEntity.isShowMatName()) {
|
orderDetailEntityJsonObject.addProperty("MatName", orderDetailEntity.getMatName());
|
}
|
|
orderDetailEntityJsonObject.addProperty("MatCode", orderDetailEntity.getMatCode());
|
orderDetailEntityJsonObject.addProperty("isShowMatCode", settingEntity.isShowMatCode());
|
orderDetailEntityJsonObject.addProperty("isShowMatName", settingEntity.isShowMatName());
|
orderDetailEntityJsonObject.addProperty("isShowSpecial", settingEntity.isShowSpecial());
|
orderDetailEntityJsonObject.addProperty("isShowPrice", settingEntity.isShowPrice());
|
orderDetailEntityJsonObject.addProperty("isShowPoints", settingEntity.isShowPoints());
|
orderDetailEntityJsonObject.addProperty("isShowBrand", settingEntity.isShowBrand());
|
orderDetailEntityJsonObject.addProperty("StockDisplay", settingEntity.getStockDisplay());
|
|
//是否显示:退货按钮
|
orderDetailEntityJsonObject.addProperty("isShowReturnButton", settingEntity.isAllowReturnOrder()&&cltCode.equals(orderEntity.getCltCode()) && orderEntity.getDocStatus()!=null&&orderEntity.getDocStatus().equals(100)&&orderDetailEntity.getPickDigit() != 0 && (orderDetailEntity.getTuiHuoKaiDanStatusItem()==null ||"".equals(orderDetailEntity.getTuiHuoKaiDanStatusItem())) ?true:false);
|
|
//最小起订数量
|
orderDetailEntityJsonObject.addProperty("Mininum", orderDetailEntity.getMininum());
|
|
if (settingEntity.isShowSpecial()) {
|
orderDetailEntityJsonObject.addProperty("Special", orderDetailEntity.getSpecial());
|
}
|
|
|
if (orderDetailEntity.getOptionJson() !=null && !"".equals(orderDetailEntity.getOptionJson())) {
|
//Map<String,Object> lists=gson.fromJson(cartEntity.getOptionJson(),new TypeToken<Map<String,Object>>(){}.getType());
|
orderDetailEntityJsonObject.addProperty("OptionJson", orderDetailEntity.getOptionJson()) ; //gson.toJson(settingEntity));
|
}
|
|
if (settingEntity.isShowPrice()) {
|
orderDetailEntityJsonObject.addProperty("Price", orderDetailEntity.getPrice() ); // 实际价格
|
orderDetailEntityJsonObject.addProperty("Currency", currencyEntity.getCurrency());
|
orderDetailEntityJsonObject.addProperty("CurrencySign", currencyEntity.getCurrencySign());
|
}
|
|
orderDetailEntityJsonObject.addProperty("TotalMoney", orderDetailEntity.getTotalMoney() ); // 当前商品金额
|
orderDetailEntityJsonObject.addProperty("ReduceAmount", orderDetailEntity.getReduceAmount() ); // 优惠金额
|
orderDetailEntityJsonObject.addProperty("ChargesAmount", orderDetailEntity.getChargesAmount() ); // 增加的费用
|
orderDetailEntityJsonObject.addProperty("BalanceAmount", orderDetailEntity.getBalanceAmount() ); // 订单行实付金额 = 当前商品金额 - 优惠金额 + 增加的费用
|
orderDetailEntityJsonObject.addProperty("ReturningAmount", orderDetailEntity.getReturningAmount() ); // 订单行可退款项 = 当前商品金额 - 优惠金额
|
|
//取出导购上传的图片
|
JsonArray orderDetailImageJsonArray = new JsonArray();
|
if (orderDetailEntity.getImages() != null && !"".equals(orderDetailEntity.getImages())) {
|
String unids[] = orderDetailEntity.getImages().split(";") ;
|
String unid = unids[0] ;
|
for (int m = 0 ;m < unids.length;m++) {
|
if (m == 0) continue ;
|
String seq = unids[m] ;
|
JsonObject unidSeqJson = new JsonObject();
|
unidSeqJson.addProperty(SettingKey.UNID,unid) ;
|
unidSeqJson.addProperty("seq",seq) ;
|
unidSeqJson.addProperty("url",imgData.getImageUrl(unid +";" + seq, settingEntity.getImageProductWidth(),
|
settingEntity.getImageProductHeight(), settingEntity.isShowProductOrgImage(),
|
settingEntity.isFromCached(), request) ) ;
|
orderDetailImageJsonArray.add(unidSeqJson) ;
|
}
|
}
|
orderDetailEntityJsonObject.add("Images",orderDetailImageJsonArray) ;
|
|
orderDetailEntityJsonObject.addProperty("Quantity", orderDetailEntity.getDigit()) ;
|
orderDetailEntityJsonObject.addProperty("RowId", orderDetailEntity.getRowId());
|
|
orderDetailEntityJsonObject.addProperty("skuId1", orderDetailEntity.getSkuId1());
|
orderDetailEntityJsonObject.addProperty("skuName1", orderDetailEntity.getSkuName1());
|
orderDetailEntityJsonObject.addProperty("skuId2", orderDetailEntity.getSkuId2());
|
orderDetailEntityJsonObject.addProperty("skuName2", orderDetailEntity.getSkuName2());
|
orderDetailEntityJsonObject.addProperty("skuId3", orderDetailEntity.getSkuId3());
|
orderDetailEntityJsonObject.addProperty("skuName3", orderDetailEntity.getSkuName3());
|
orderDetailEntityJsonObject.addProperty("skuId4", orderDetailEntity.getSkuId4());
|
orderDetailEntityJsonObject.addProperty("skuName4", orderDetailEntity.getSkuName4());
|
orderDetailEntityJsonObject.addProperty("skuId5", orderDetailEntity.getSkuId5());
|
orderDetailEntityJsonObject.addProperty("skuName5", orderDetailEntity.getSkuName5());
|
orderDetailEntityJsonObject.addProperty("skuId6", orderDetailEntity.getSkuId6());
|
orderDetailEntityJsonObject.addProperty("skuName6", orderDetailEntity.getSkuName6());
|
orderDetailEntityJsonObject.addProperty("skuId7", orderDetailEntity.getSkuId7());
|
orderDetailEntityJsonObject.addProperty("skuName7", orderDetailEntity.getSkuName7());
|
orderDetailEntityJsonObject.addProperty("skuId8", orderDetailEntity.getSkuId8());
|
orderDetailEntityJsonObject.addProperty("skuName8", orderDetailEntity.getSkuName8());
|
orderDetailEntityJsonObject.addProperty("skuId9", orderDetailEntity.getSkuId9());
|
orderDetailEntityJsonObject.addProperty("skuName9", orderDetailEntity.getSkuName9());
|
orderDetailEntityJsonObject.addProperty("skuId10", orderDetailEntity.getSkuId10());
|
orderDetailEntityJsonObject.addProperty("skuName10", orderDetailEntity.getSkuName10());
|
|
|
totalQuantity += orderDetailEntity.getDigit();
|
itemCount ++ ;
|
orderDetailListJsonArray.add(orderDetailEntityJsonObject);
|
}
|
|
json.add("list", orderDetailListJsonArray);
|
json.addProperty("TotalQuantity",df.format(totalQuantity)); //所有商品总“数量”
|
json.addProperty("ItemCount",itemCount); //有多少种类商品
|
json.addProperty("GroupBuyingDocCode",orderEntity.getGroupBuyingDocCode()); //团购订单号
|
json.addProperty("GroupBuyingHasMembers",orderEntity.getGroupBuyingHasMembers()!=null&& orderEntity.getGroupBuyingHasMembers().intValue() >0?orderEntity.getGroupBuyingHasMembers():0); //已经成团人数
|
Integer groupBuyingMembersBalance = 0;
|
if (orderEntity.getGroupBuyingDocCode()!=null && !"".equals(orderEntity.getGroupBuyingDocCode())) {
|
OrderDetailEntity orderDetailEntity = orderDetailList != null&&orderDetailList.size()>0? orderDetailList.get(0):null;
|
if (orderDetailEntity != null && orderDetailEntity.getGroupBuyingMembers()!=null && orderEntity.getGroupBuyingHasMembers()!=null) {
|
//已成团人数 - 成团人数
|
groupBuyingMembersBalance = orderEntity.getGroupBuyingHasMembers().intValue() - orderDetailEntity.getGroupBuyingMembers().intValue() ;
|
}
|
}
|
json.addProperty("GroupBuyingMembersBalance",groupBuyingMembersBalance); //团购余额:还差多少人成团
|
|
//显示拼团详细人员列表
|
List<GroupBuyingEntity>groupBuyingList = orderIfc.getGroupBuyingOrderList( orderEntity.getGroupBuyingDocCode()) ;
|
JsonArray groupBuyingListJsonArray = new JsonArray();
|
for (int i = 0; groupBuyingList !=null && i < groupBuyingList.size(); i++) {
|
GroupBuyingEntity groupBuyingEntity = groupBuyingList.get(i);
|
JsonObject groupBuyingEntityJsonObject = new JsonObject();
|
groupBuyingEntityJsonObject.addProperty("OpenId", groupBuyingEntity.getOpenId());
|
groupBuyingEntityJsonObject.addProperty("NickName", groupBuyingEntity.getNickName());
|
groupBuyingEntityJsonObject.addProperty("NickName", groupBuyingEntity.getNickName());
|
groupBuyingEntityJsonObject.addProperty("Headimgurl", groupBuyingEntity.getHeadimgurl());
|
groupBuyingEntityJsonObject.addProperty("WeiXinAvatarUnid", groupBuyingEntity.getWeiXinAvatarUnid());
|
groupBuyingEntityJsonObject.addProperty("EnterDate", sdf3.format(groupBuyingEntity.getEnterDate()));
|
groupBuyingEntityJsonObject.addProperty("isGroupBuyingMaster", groupBuyingEntity.isGroupBuyingMaster());
|
groupBuyingListJsonArray.add(groupBuyingEntityJsonObject);
|
}
|
json.add("groupBuyingList", groupBuyingListJsonArray);
|
|
|
this.printJson(response, json.toString());
|
|
return ;
|
|
}catch(DataAccessException e ) {
|
e.printStackTrace();
|
errJson.addProperty("warning", e.getCause() != null ?e.getCause().getMessage():e.getMessage());
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}catch(Exception e){
|
e.printStackTrace();
|
errJson.addProperty("warning", e.getMessage());
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
@RequestMapping("/shopping/groupBuyingOrderList.do")
|
public void groupBuyingOrderList(HttpServletRequest request,HttpServletResponse response) {
|
//HttpSession session=request.getSession();
|
JsonObject json = new JsonObject();
|
JsonObject errJson = new JsonObject();
|
SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm") ;
|
String groupBuyingDocCode = request.getParameter(SettingKey.GROUPBUYINGDOCCODE);
|
try {
|
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ;
|
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源
|
//显示拼团详细人员列表
|
List<GroupBuyingEntity>groupBuyingList = orderIfc.getGroupBuyingOrderList( groupBuyingDocCode) ;
|
JsonArray groupBuyingListJsonArray = new JsonArray();
|
for (int i = 0; groupBuyingList !=null && i < groupBuyingList.size(); i++) {
|
GroupBuyingEntity groupBuyingEntity = groupBuyingList.get(i);
|
JsonObject groupBuyingEntityJsonObject = new JsonObject();
|
groupBuyingEntityJsonObject.addProperty("OpenId", groupBuyingEntity.getOpenId());
|
groupBuyingEntityJsonObject.addProperty("NickName", groupBuyingEntity.getNickName());
|
groupBuyingEntityJsonObject.addProperty("NickName", groupBuyingEntity.getNickName());
|
groupBuyingEntityJsonObject.addProperty("Headimgurl", groupBuyingEntity.getHeadimgurl());
|
groupBuyingEntityJsonObject.addProperty("WeiXinAvatarUnid", groupBuyingEntity.getWeiXinAvatarUnid());
|
groupBuyingEntityJsonObject.addProperty("EnterDate", sdf3.format(groupBuyingEntity.getEnterDate()));
|
groupBuyingEntityJsonObject.addProperty("isGroupBuyingMaster", groupBuyingEntity.isGroupBuyingMaster());
|
groupBuyingListJsonArray.add(groupBuyingEntityJsonObject);
|
}
|
json.add("groupBuyingList", groupBuyingListJsonArray);
|
this.printJson(response, json.toString());
|
|
return ;
|
|
}catch(DataAccessException e ) {
|
e.printStackTrace();
|
errJson.addProperty("warning", e.getCause() != null ?e.getCause().getMessage():e.getMessage());
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}catch(Exception e){
|
e.printStackTrace();
|
errJson.addProperty("warning", e.getMessage());
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
@RequestMapping("/shopping/orderReceipt.do")
|
public void updateOrderReceipt(HttpServletRequest request,HttpServletResponse response) {
|
HttpSession session=request.getSession();
|
String cltCode = (session.getAttribute(SettingKey.CLTCODE)==null?"":(String)session.getAttribute(SettingKey.CLTCODE));
|
//String userCode = (session.getAttribute(SessionKey.USERCODE) == null ? ""
|
// : (String)session.getAttribute(SessionKey.USERCODE));
|
String docCode=request.getParameter(SettingKey.DOCCODE)==null?"":request.getParameter(SettingKey.DOCCODE);
|
//将微信corpid组装成url
|
//String wxQueryString = SettingKey.getQueryStringByWx(request);
|
//boolean isMoblieBrowser = SettingKey.isMoblieBrowser(request);
|
//String hostUrl = SettingKey.getHostUrl(request) ;
|
|
JsonObject json = new JsonObject();
|
JsonObject errJson = new JsonObject();
|
|
try {
|
DataSourceEntity dataSourceEntity = MultiDataSource.getDataSourceMap( request) ;
|
SpObserver.setDBtoInstance("_"+dataSourceEntity.getDbId());//切换数据源
|
|
//检查该客户是否存在
|
if (cltCode != null && !"".equals(cltCode)) {
|
|
CustomerEntity customerEntity = accountIfc.getLoginInfoByCltCode(cltCode,cltCode,cltCode);
|
if (customerEntity==null || customerEntity.getCltCode()==null||customerEntity.getCltCode().equals("")) {
|
cltCode = null;
|
session.removeAttribute(SettingKey.CLTCODE);
|
}
|
}
|
|
if (cltCode == null || "".equals(cltCode) ) {
|
json.addProperty(SettingKey.CLTCODE,"");
|
return ;
|
}else {
|
json.addProperty(SettingKey.CLTCODE,cltCode);
|
}
|
boolean ret = orderIfc.updateOrderReceipt(cltCode,docCode) ;
|
|
json.addProperty("state", ret ? "success": "falied");
|
this.printJson(response, json.toString());
|
return;
|
|
}catch(DataAccessException e ) {
|
e.printStackTrace();
|
errJson.addProperty("warning", e.getCause() != null ?e.getCause().getMessage():e.getMessage());
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}catch(Exception e){
|
e.printStackTrace();
|
errJson.addProperty("warning", e.getMessage());
|
json.add("error", errJson);
|
this.printJson(response, json.toString());
|
return;
|
}finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
}
|