json字符串参数
jsp部分 json字符串的属性应该都是实体类的属性
function saveCashier(){
layer.closeAll();
var Reapply = document.getElementById('isReapply');
if(actcardflag>0&&Reapply.checked){
isReapply=1;
}
var memo = $('#memo').val();
var customerName = $('#customerName').val();
var customerId = $('#customerId').val();
var discountPrice = Number($('#saleMoney').val())+Number($('#packagecardmoney').val());
var cashMoney = $('#cashMoney').val();
var unionpayMoney = $('#unionpayMoney').val();
var ailipayMoney = $('#ailipayMoney').val();
var weixinMoney = $('#weixinMoney').val();
var otherMoney = $('#otherMoney').val();
var createDatetime = $('#createDatetime').val();
var packagecardmoney = $('#packagecardmoney').val();
var receivedprice =Number(0) + Number($('#cashMoney').val()) + Number($('#unionpayMoney').val()) + Number($('#ailipayMoney').val()) + Number($('#weixinMoney').val()) + Number($('#otherMoney').val())+Number($('#storedcardmoney').val())+Number($('#packagecardmoney').val());
if(refundcardflag>0){
receivedprice = 0 - Number($('#refundMoney').val())
}
var signature = $('#signature').val();
var storedcardmoney = $('#storedcardmoney').val();
var str = '{"isreapply":"'+isReapply+'","signature":"'+signature+'","createdatetime":"' + createDatetime + '","othermoney":"' + otherMoney + '","weixinmoney":"' + weixinMoney + '","ailipaymoney":"' + ailipayMoney + '","unionpaymoney":"' + unionpayMoney + '","cashmoney":"' + cashMoney + '","storedcardmoney":"' + storedcardmoney + '","packagecardmoney":"' + packagecardmoney + '","discountprice":"' + discountPrice + '","receivedprice":"' + receivedprice + '","customerid":"' + customerId + '","customername":"' + customerName + '","memo":"' + memo + '","consumptionDetails": [';
var itemStr = '';
//开卡
if(actcardflag>0){
$(".icard").each(function() {
if(itemStr.length>1){
itemStr += ',';
}
var icardtype = $(this).attr("itype");
var busid = 0;
var cardtypeid = $(this).val();
var price = $("#cardMoney").val();
price = Number(price);
var givemoney = 0
if(icardtype==1){
busid = 5;
}
if(icardtype==2){
busid = 3;
givemoney = Number($("#giveMoney").val());
}
if(icardtype==3){
busid = 9;
}
itemStr += '{"cardtypeid":"'+cardtypeid+'","busid":"'+busid+'","money":"'+price+'","discountprice":"'+price+'","givemoney":"'+givemoney+'","consumptionAchievements": [';
var achStr = '';
$(this).parent().find("span.postAch").each(function() {
if(achStr.length>1){
achStr += ',';
}
var achievement = $(this).attr("achievement");
var salesid = $(this).attr("userid");
var handprice = $(this).attr("handprice");
if(achievement!=0||handprice!=0){
achStr += '{"salesid":"'+salesid+'","achievement":"'+achievement+'","handprice":"'+handprice+'"}';
}
})
itemStr += achStr;
itemStr += ']';
//开疗程卡或大项目卡
if(icardtype==1||icardtype==3){
itemStr += ',"consumptionItems": [';
var pstr = '';
$(".carditem").each(function() {
if(pstr.length>1){
pstr += ',';
}
var iname = $(this).attr("iname");
var itype=$(this).attr("itype");
var itemid = $(this).val();
var originalquantity = $(this).parent().parent().find("input:eq(1)").val();
var usequantity = $(this).parent().parent().find("input:eq(2)").val();
var quantity = Number(originalquantity) - Number(usequantity);
var price = $(this).parent().parent().find("input:eq(3)").val();
var handPrice = $(this).parent().parent().find("input:eq(4)").val();
var unitAchievement = $(this).parent().parent().find("input:eq(5)").val();
var isgift = 0;
if(itype>10){
isgift = 1;
}
pstr += '{"itemid":"'+itemid+'","itype":"'+itype+'","iname":"'+iname+'","quantity":"'+quantity+'","originalquantity":"'+originalquantity+'","price":"'+price+'","handPrice":"'+handPrice+'","unitAchievement":"'+unitAchievement+'","isgift":"'+isgift+'"}';
});
itemStr += pstr;
itemStr += ']';
}
itemStr += '}';
});
}
//零售
if(retailflag>0){
$(".item").each(function() {
var productid = 0;
var projectid = 0;
var busid = $(this).attr("itype");
if(busid==1){
productid = $(this).val();
}
if(busid==2){
projectid = $(this).val();
}
var price = $(this).parent().parent().find("input:eq(2)").val();
var quantity = $(this).parent().parent().find("input:eq(3)").val();
var discountPrice = Number(quantity) * Number(price);
if(quantity > 0) {
if(itemStr.length>1){
itemStr += ',';
}
itemStr += '{"productid":"'+productid+'","projectid":"'+projectid+'","quantity":"'+quantity+'","busid":"'+busid+'","price":"'+price+'","discountprice":"'+discountPrice+'","consumptionAchievements": [';
var achStr = '';
$(this).parent().parent().find("span.postAch").each(function() {
if(achStr.length>1){
achStr += ',';
}
var achievement = $(this).attr("achievement");
var salesid = $(this).attr("userid");
var handprice = $(this).attr("handprice");
if(achievement!=0||handprice!=0){
achStr += '{"salesid":"'+salesid+'","achievement":"'+achievement+'","handprice":"'+handprice+'"}';
}
})
itemStr += achStr;
itemStr += ']}';
}
});
}
//储值卡消费
if(storedcardflag>0){
var cardid = $("#cardclass").val();
$(".item").each(function() {
var productid = 0;
var projectid = 0;
var busid = $(this).attr("itype");
if(busid==1){
productid = $(this).val();
busid = 11;
}
if(busid==2){
projectid = $(this).val();
busid = 12;
}
var price = $(this).parent().parent().find("input:eq(2)").val();
var quantity = $(this).parent().parent().find("input:eq(3)").val();
var discountPrice = Number(quantity) * Number(price);
if(quantity > 0) {
if(itemStr.length>1){
itemStr += ',';
}
itemStr += '{"cardid":"'+cardid+'","productid":"'+productid+'","projectid":"'+projectid+'","quantity":"'+quantity+'","busid":"'+busid+'","price":"'+price+'","discountprice":"'+discountPrice+'","consumptionAchievements": [';
var achStr = '';
$(this).parent().parent().find("span.postAch").each(function() {
if(achStr.length>1){
achStr += ',';
}
var achievement = $(this).attr("achievement");
var salesid = $(this).attr("userid");
var handprice = $(this).attr("handprice");
if(achievement!=0||handprice!=0){
achStr += '{"salesid":"'+salesid+'","achievement":"'+achievement+'","handprice":"'+handprice+'"}';
}
})
itemStr += achStr;
itemStr += ']}';
}
});
}
//疗程卡消费
if(packagecardflag>0){
$(".packagecardclass").each(function() {
var cardid = $(this).val();
$(this).parent().find(".packageitem").each(function() {
var productid = 0;
var projectid = 0;
var busid = $(this).attr("itype");
if(busid==1){
productid = $(this).val();
busid = 14;
}
if(busid==2){
projectid = $(this).val();
busid = 15;
}
var price = $(this).parent().parent().find("input:eq(0)").attr("price");
var quantity = $(this).parent().parent().find("input:eq(3)").val();
var discountPrice = Number(quantity) * Number(price);
if(quantity > 0) {
if(itemStr.length>1){
itemStr += ',';
}
itemStr += '{"cardid":"'+cardid+'","productid":"'+productid+'","projectid":"'+projectid+'","quantity":"'+quantity+'","busid":"'+busid+'","price":"'+price+'","discountprice":"'+discountPrice+'","consumptionAchievements": [';
var achStr = '';
$(this).parent().parent().find("span.postAch").each(function() {
if(achStr.length>1){
achStr += ',';
}
var achievement = $(this).attr("achievement");
var salesid = $(this).attr("userid");
var handprice = $(this).attr("handprice");
if(achievement!=0||handprice!=0){
achStr += '{"salesid":"'+salesid+'","achievement":"'+achievement+'","handprice":"'+handprice+'"}';
}
})
itemStr += achStr;
itemStr += ']}';
}
});
});
}
//大项目卡消费
if(bigcardflag>0){
$(".bigcardclass").each(function() {
var cardid = $(this).val();
$(this).parent().find(".bigitem").each(function() {
var busid = 16;
var productid = 0;
var projectid = $(this).val();
var price = Number($(this).parent().parent().find("input:eq(0)").attr("price"));
var quantity = $(this).parent().parent().find("input:eq(3)").val();
var discountPrice = Number(quantity) * Number(price);
if(quantity > 0) {
if(itemStr.length>1){
itemStr += ',';
}
itemStr += '{"cardid":"'+cardid+'","productid":"'+productid+'","projectid":"'+projectid+'","quantity":"'+quantity+'","busid":"'+busid+'","price":"'+price+'","discountprice":"'+discountPrice+'","consumptionAchievements": [';
var achStr = '';
$(this).parent().parent().find("span.postAch").each(function() {
if(achStr.length>1){
achStr += ',';
}
var achievement = $(this).attr("achievement");
var salesid = $(this).attr("userid");
var handprice = $(this).attr("handprice");
if(achievement!=0||handprice!=0){
achStr += '{"salesid":"'+salesid+'","achievement":"'+achievement+'","handprice":"'+handprice+'"}';
}
})
itemStr += achStr;
itemStr += ']}';
}
});
});
}
//充值
if(rechargeflag>0){
$(".rechargeitem").each(function() {
if(itemStr.length>1){
itemStr += ',';
}
var busid = 4;
var cardid = $(this).val();
var price = $("#rechargeMoney").val();
price = Number(price);
var givemoney = Number($("#rechargeGiveMoney").val());
itemStr += '{"cardid":"'+cardid+'","busid":"'+busid+'","money":"'+price+'","discountprice":"'+price+'","givemoney":"'+givemoney+'","consumptionAchievements": [';
var achStr = '';
$(this).parent().parent().find("span.postAch").each(function() {
if(achStr.length>1){
achStr += ',';
}
var achievement = $(this).attr("achievement");
var salesid = $(this).attr("userid");
var handprice = $(this).attr("handprice");
if(achievement!=0||handprice!=0){
achStr += '{"salesid":"'+salesid+'","achievement":"'+achievement+'","handprice":"'+handprice+'"}';
}
})
itemStr += achStr;
itemStr += ']';
itemStr += '}';
});
}
//退卡
if(refundcardflag>0){
$(".refunditem").each(function() {
if(itemStr.length>1){
itemStr += ',';
}
var busid = 0;
var ctype = $(this).attr("ctype");
if(ctype==1){
busid = 7;//退疗程卡
}
if(ctype==2){
busid = 6;//退储值卡
}
if(ctype==3){
busid = 10;//退大项目卡
}
var cardid = $(this).val();
var price = 0 - $("#refundMoney").val();
var givemoney = Number($("#rechargeGiveMoney").val());
itemStr += '{"cardid":"'+cardid+'","busid":"'+busid+'","money":"'+price+'","discountprice":"'+price+'","consumptionAchievements": [';
var achStr = '';
$(this).parent().parent().find("span.postAch").each(function() {
if(achStr.length>1){
achStr += ',';
}
var achievement = $(this).attr("achievement");
var salesid = $(this).attr("userid");
var handprice = $(this).attr("handprice");
if(achievement!=0||handprice!=0){
achStr += '{"salesid":"'+salesid+'","achievement":"'+achievement+'","handprice":"'+handprice+'"}';
}
})
itemStr += achStr;
itemStr += ']';
itemStr += '}';
});
}
//储值卡购疗程卡(两条消费详情,一条开卡,一条储值卡消费)
if(storedpackagecardflag>0){
$(".icard").each(function() {
if(itemStr.length>1){
itemStr += ',';
}
//开疗程卡
var icardtype = $(this).attr("itype");
var cardtypeid = $(this).val();
var price = $("#cardMoney").val();
price = Number(price);
var givemoney = 0;
var busid = 5;
itemStr += '{"cardtypeid":"'+cardtypeid+'","busid":"'+busid+'","money":"'+price+'","discountprice":"'+price+'","givemoney":"'+givemoney+'","consumptionAchievements": []';
itemStr += ',"consumptionItems": [';
var pstr = '';
$(".carditem").each(function() {
if(pstr.length>1){
pstr += ',';
}
var iname = $(this).attr("iname");
var itype=$(this).attr("itype");
var itemid = $(this).val();
var originalquantity = $(this).parent().parent().find("input:eq(1)").val();
var usequantity = $(this).parent().parent().find("input:eq(2)").val();
var quantity = Number(originalquantity) - Number(usequantity);
var price = $(this).parent().parent().find("input:eq(3)").val();
var handPrice = $(this).parent().parent().find("input:eq(4)").val();
var unitAchievement = $(this).parent().parent().find("input:eq(5)").val();
var isgift = 0;
if(itype>10){
isgift = 1;
}
pstr += '{"itemid":"'+itemid+'","itype":"'+itype+'","iname":"'+iname+'","quantity":"'+quantity+'","originalquantity":"'+originalquantity+'","price":"'+price+'","handPrice":"'+handPrice+'","unitAchievement":"'+unitAchievement+'","isgift":"'+isgift+'"}';
});
itemStr += pstr;
itemStr += ']';
itemStr += '}';
});
//耗储值卡
busid = 13;
var price = Number($("#cardMoney").val());
var cardid = $(".buypackageitem").val();
if(itemStr.length>1){
itemStr += ',';
}
itemStr += '{"cardid":"'+cardid+'","busid":"'+busid+'","money":"'+price+'","discountprice":"'+price+'","consumptionAchievements": [';
var achStr = '';
//业绩存在耗储值卡底下
$(".icard").each(function() {
$(this).parent().find("span.postAch").each(function() {
if(achStr.length>1){
achStr += ',';
}
var achievement = $(this).attr("achievement");
var salesid = $(this).attr("userid");
var handprice = $(this).attr("handprice");
if(achievement!=0||handprice!=0){
achStr += '{"salesid":"'+salesid+'","achievement":"'+achievement+'","handprice":"'+handprice+'"}';
}
})
});
itemStr += achStr;
itemStr += ']';
itemStr += '}';
}
if(repayflag>0){
$(".repayclass").each(function() {
var proName = $(this).parent().next().text();
var price = $(this).parent().parent().find("input:eq(2)").val();
var quantity = $(this).parent().parent().find("input:eq(3)").val();
var discountPrice = Number(quantity) * Number(price);
var debtid = $(this).val();
if(discountPrice > 0) {
if(itemStr.length>1){
itemStr += ',';
}
var busid = 8;
itemStr += '{"busid":"'+busid+'","price":"'+discountPrice+'","discountprice":"'+discountPrice+'","debtid":"'+debtid+'","consumptionAchievements": [';
var achStr = '';
$(this).parent().parent().find("span.postAch").each(function() {
if(achStr.length>1){
achStr += ',';
}
var achievement = $(this).attr("achievement");
var salesid = $(this).attr("userid");
var handprice = $(this).attr("handprice");
if(achievement!=0||handprice!=0){
achStr += '{"salesid":"'+salesid+'","achievement":"'+achievement+'","handprice":"'+handprice+'"}';
}
})
itemStr += achStr;
itemStr += ']';
itemStr += '}';
}
});
}
//详情json结束
str += itemStr;
str += ']';
if(discountPrice != receivedprice && isReapply!=1){
var debtmoney = discountPrice - receivedprice;
str += ',"consumptionDebts": [';
str += '{"money":"'+debtmoney+'"}';
str += ']';
}
str += '}';
$.ajax({
url: '${ctx}/cashier/saveCashier',
type: 'post',
traditional:true,
data:{
str:str
},success:function(data){
location.reload();
},error:function(){
alert('网络错误,请重新登录!');
}
});
}
---------------------------------------------------------------------------------------------------------------------------
@ResponseBody
@RequestMapping(value = { "/saveCashier" }, method = RequestMethod.POST)
public String saveCashier(
@RequestParam(value = "str", required = false) String str,
HttpServletRequest request, Model model) throws JsonParseException,
JsonMappingException, IOException {
Object objuser = request.getSession().getAttribute("user");
Object objshopid = request.getSession().getAttribute("shopid");
Integer shopid = (Integer) objshopid;
User user = (User) objuser;
ObjectMapper mapper = new ObjectMapper(); //json字符串转化为实体对象
Consumption consumption = mapper.readValue(str, Consumption.class);
consumption.setShopid(shopid);
consumption.setCashierid(user.getId());
cashierService.saveCashierConsumption(consumption);
return "1";
}
------------------------------------------------------------------------------------------------------------------------------------------
private static final String STR_FORMAT = "0000000000000000";
public void saveCashierConsumption(Consumption consumption) {
consumption.setStatus(1);
consumption.setStatisticstatus(0);
if(consumption.getIsreapply()==1){
consumption.setOriginalprice(consumption.getDiscountprice());
consumption.setDiscountprice(new BigDecimal(0));
consumption.setReceivedprice(new BigDecimal(0));
consumption.setStoredcardmoney(new BigDecimal(0));
consumption.setPackagecardmoney(new BigDecimal(0));
consumption.setCashmoney(new BigDecimal(0));
consumption.setUnionpaymoney(new BigDecimal(0));
consumption.setWeixinmoney(new BigDecimal(0));
consumption.setAilipaymoney(new BigDecimal(0));
consumption.setOthermoney(new BigDecimal(0));
}
consumptionMapper.insertSelectiveWithReturnId(consumption);
DecimalFormat df = new DecimalFormat(STR_FORMAT);
String orderNo = df.format(consumption.getId()); //格式化
consumption.setOrderno(orderNo);
String busid = "";
// 利用set去重busid
Set<Integer> busidSet = new HashSet<Integer>();
// 消费详情
for (ConsumptionDetail detail : consumption.getConsumptionDetails()) {
detail.setConsumptionid(consumption.getId());
detail.setCreatedatetime(consumption.getCreatedatetime());
if(consumption.getIsreapply()==1){
detail.setDiscountprice(new BigDecimal(0));
}
consumptionDetailMapper.insertSelectiveWithReturnId(detail);
// 开储值卡
if (detail.getBusid() == BusType.actStored.getIndex()) {
StoredCard storedCard = storedCardMapper
.selectByPrimaryKey(detail.getCardtypeid());
CustomerStoredCard customerStoredCard = new CustomerStoredCard();
customerStoredCard.setCardname(storedCard.getCardname());
customerStoredCard.setCardtypeid(storedCard.getId());
customerStoredCard.setCreatedatetime(consumption
.getCreatedatetime());
customerStoredCard.setCustomerid(consumption.getCustomerid());
customerStoredCard.setGivemoney(detail.getGivemoney());
customerStoredCard.setMoney(detail.getMoney());
customerStoredCard.setStatus(1);
if(consumption.getIsreapply()==1){
customerStoredCard.setIsreapply(1);
}
customerStoredCardMapper
.insertSelectiveWithReturnId(customerStoredCard);
String cardNo = "C"
+ df.format(customerStoredCard.getId()).substring(1); //substring(1) 相当于从第二位开始截取,相当于去掉开头第一个0
customerStoredCard.setCardno(cardNo);
customerStoredCardMapper
.updateByPrimaryKeySelective(customerStoredCard);
detail.setCardid(customerStoredCard.getId());
}
// 开疗程卡
if (detail.getBusid() == BusType.actPackage.getIndex()) {
// 开卡
PackageCard packageCard = packageCardMapper
.selectByPrimaryKey(detail.getCardtypeid());
CustomerPackageCard customerPackageCard = new CustomerPackageCard();
customerPackageCard.setCustomerid(consumption.getCustomerid());
customerPackageCard.setCardname(packageCard.getCardname());
customerPackageCard.setPrice(detail.getMoney());
customerPackageCard.setCardtypeid(packageCard.getId());
customerPackageCard.setCreatedatetime(consumption
.getCreatedatetime());
customerPackageCard.setStatus(1);
if(consumption.getIsreapply()==1){
customerPackageCard.setIsreapply(1);
}
customerPackageCardMapper
.insertSelectiveWithReturnId(customerPackageCard);
String cardNo = "L"
+ df.format(customerPackageCard.getId()).substring(1);
customerPackageCard.setCardno(cardNo);
customerPackageCardMapper
.updateByPrimaryKeySelective(customerPackageCard);
detail.setCardid(customerPackageCard.getId());
for (ConsumptionItem item : detail.getConsumptionItems()) {
// 产品或赠送产品
if (item.getItype() == 1 || item.getItype() == 11) {
CustomerPackageCardProduct cpProduct = new CustomerPackageCardProduct();
cpProduct.setCardid(customerPackageCard.getId());
cpProduct.setIsgift(item.getIsgift());
cpProduct.setOriginalquantity(item
.getOriginalquantity());
cpProduct.setQuantity(item.getQuantity());
cpProduct.setPrice(item.getPrice());
cpProduct.setProductid(item.getItemid());
cpProduct.setProductname(item.getIname());
customerPackageCardProductMapper
.insertSelective(cpProduct);
}
// 项目或赠送项目
if (item.getItype() == 2 || item.getItype() == 12) {
CustomerPackageCardProject cpProject = new CustomerPackageCardProject();
cpProject.setCardid(customerPackageCard.getId());
cpProject.setIsgift(item.getIsgift());
cpProject.setOriginalquantity(item
.getOriginalquantity());
cpProject.setQuantity(item.getQuantity());
cpProject.setHandprice(item.getHandPrice());
cpProject.setProjectid(item.getItemid());
cpProject.setProjectname(item.getIname());
cpProject.setUnitachievement(item.getUnitAchievement());
cpProject.setUnitprice(item.getPrice());
customerPackageCardProjectMapper
.insertSelective(cpProject);
}
}
}
// 开大项目卡
if (detail.getBusid() == BusType.actBigProject.getIndex()) {
BigProjectCard bigProjectCard = bigProjectCardMapper
.selectByPrimaryKey(detail.getCardtypeid());
CustomerBigProjectCard customerBigProjectCard = new CustomerBigProjectCard();
customerBigProjectCard
.setCardname(bigProjectCard.getCardname());
customerBigProjectCard.setCardtypeid(bigProjectCard.getId());
customerBigProjectCard.setCreatedate(consumption
.getCreatedatetime());
customerBigProjectCard.setCustomerid(consumption
.getCustomerid());
customerBigProjectCard.setPrice(detail.getMoney());
customerBigProjectCard.setStatus(1);
if(consumption.getIsreapply()==1){
customerBigProjectCard.setIsreapply(1);
}
customerBigProjectCardMapper
.insertSelectiveWithReturnId(customerBigProjectCard);
String cardNo = "D"
+ df.format(customerBigProjectCard.getId())
.substring(1);
customerBigProjectCard.setCardno(cardNo);
customerBigProjectCardMapper
.updateByPrimaryKeySelective(customerBigProjectCard);
detail.setCardid(customerBigProjectCard.getId());
// 卡包含的大项目
for (ConsumptionItem item : detail.getConsumptionItems()) {
CustomerBigProjectCardProject cb = new CustomerBigProjectCardProject();
cb.setCardid(customerBigProjectCard.getId());
cb.setBigprojectid(item.getItemid());
cb.setBigprojectname(item.getIname());
cb.setOriginalquantity(item.getOriginalquantity());
cb.setQuantity(item.getQuantity());
cb.setPrice(item.getPrice());
customerBigProjectCardProjectMapper.insertSelective(cb);
}
}
//零售产品
if(detail.getBusid() == BusType.product.getIndex()){
stockConsume(detail.getProductid(),detail.getQuantity(),consumption.getCashierid());
}
// 储值卡买产品
if (detail.getBusid() == BusType.storedProduct.getIndex()) {
CustomerStoredCard card = customerStoredCardMapper
.selectByPrimaryKey(detail.getCardid());
storedCardConsumption(detail.getCardid(),
detail.getDiscountprice());
detail.setCardtypeid(card.getCardtypeid());
stockConsume(detail.getProductid(),detail.getQuantity(),consumption.getCashierid());
}
// 储值卡买项目
if (detail.getBusid() == BusType.storedProject.getIndex()) {
CustomerStoredCard card = customerStoredCardMapper
.selectByPrimaryKey(detail.getCardid());
storedCardConsumption(detail.getCardid(),
detail.getDiscountprice());
detail.setCardtypeid(card.getCardtypeid());
}
// 疗程卡耗产品
if (detail.getBusid() == BusType.packageProduct.getIndex()) {
CustomerPackageCard card = customerPackageCardMapper
.selectByPrimaryKey(detail.getCardid());
packageUseProduct(detail.getCardid(), detail.getProductid(),
detail.getQuantity());
detail.setCardtypeid(card.getCardtypeid());
CustomerPackageCardProduct packageProduct = customerPackageCardProductMapper.selectByPrimaryKey(detail.getProductid());
stockConsume(packageProduct.getProductid(),detail.getQuantity(),consumption.getCashierid());
}
// 疗程卡耗项目
if (detail.getBusid() == BusType.packageProject.getIndex()) {
CustomerPackageCard card = customerPackageCardMapper
.selectByPrimaryKey(detail.getCardid());
packageUseProject(detail.getCardid(), detail.getProjectid(),
detail.getQuantity());
detail.setCardtypeid(card.getCardtypeid());
}
// 大项目卡耗项目
if (detail.getBusid() == BusType.bigProject.getIndex()) {
CustomerBigProjectCard card = customerBigProjectCardMapper
.selectByPrimaryKey(detail.getCardid());
bigcardUseProject(detail.getCardid(), detail.getProjectid(),
detail.getQuantity());
detail.setCardtypeid(card.getCardtypeid());
}
// 充值
if (detail.getBusid() == BusType.recharge.getIndex()) {
CustomerStoredCard card = customerStoredCardMapper
.selectByPrimaryKey(detail.getCardid());
storedCardRecharge(card.getId(), detail.getMoney(),
detail.getGivemoney());
detail.setCardtypeid(card.getCardtypeid());
}
// 退疗程卡
if (detail.getBusid() == BusType.refundPackage.getIndex()) {
CustomerPackageCard card = customerPackageCardMapper
.selectByPrimaryKey(detail.getCardid());
card.setStatus(0);// 退卡
customerPackageCardMapper.updateByPrimaryKeySelective(card);
detail.setCardtypeid(card.getCardtypeid());
}
// 退储值卡
if (detail.getBusid() == BusType.refundStored.getIndex()) {
CustomerStoredCard card = customerStoredCardMapper
.selectByPrimaryKey(detail.getCardid());
card.setStatus(0);// 退卡
customerStoredCardMapper.updateByPrimaryKeySelective(card);
detail.setCardtypeid(card.getCardtypeid());
}
// 退大项目卡
if (detail.getBusid() == BusType.refundProject.getIndex()) {
CustomerBigProjectCard card = customerBigProjectCardMapper
.selectByPrimaryKey(detail.getCardid());
card.setStatus(0);// 退卡
customerBigProjectCardMapper.updateByPrimaryKeySelective(card);
detail.setCardtypeid(card.getCardtypeid());
}
// 储值卡购疗程卡消耗
if (detail.getBusid() == BusType.storedPackage.getIndex()) {
CustomerStoredCard card = customerStoredCardMapper
.selectByPrimaryKey(detail.getCardid());
storedCardConsumption(detail.getCardid(),
detail.getDiscountprice());
detail.setCardtypeid(card.getCardtypeid());
}
// 还款
if (detail.getBusid() == BusType.repay.getIndex()) {
repay(detail.getDebtid(), detail.getDiscountprice());
}
busidSet.add(detail.getBusid());
// 业绩详情
for (ConsumptionAchievement achievement : detail
.getConsumptionAchievements()) {
//非补卡
if(consumption.getIsreapply()!=1){
ConsumptionAchievement ach = new ConsumptionAchievement();
ach.setParentid(detail.getId());
ach.setSalesid(achievement.getSalesid());
ach.setIsappoint(achievement.getIsappoint());
if (achievement.getAchievement().doubleValue() != 0) {
ach.setAchievement(achievement.getAchievement());
ach.setAchievetype(1);
consumptionAchievementMapper.insert(ach);
}
if (achievement.getHandprice().doubleValue() != 0) {
ach.setAchievetype(2);
ach.setAchievement(achievement.getHandprice());
consumptionAchievementMapper.insert(ach);
}
}
}
consumptionDetailMapper.updateByPrimaryKeySelective(detail);
}
// 欠款记录
if (consumption.getConsumptionDebts() != null) {
//非补卡
if(consumption.getIsreapply()!=1){
for (ConsumptionDebt debt : consumption.getConsumptionDebts()) {
debt.setConsumptionid(consumption.getId());
debt.setStatus(0);
debt.setOriginalmoney(debt.getMoney());
debt.setCreatedatetime(consumption.getCreatedatetime());
consumptionDebtMapper.insertSelective(debt);
}
}
}
// 回写busid
for (Integer i : busidSet) {
if (busid.length() > 0) {
busid += ",";
}
busid += i.toString();
}
consumption.setBusid(busid);
consumptionMapper.updateByPrimaryKeySelective(consumption);
}
----------------------------------------------------------------------------------------------------------------------------------------------
符号含义:
0 一个数字
# 一个数字,不包括 0
. 小数的分隔符的占位符
, 分组分隔符的占位符
; 分隔格式。
- 缺省负数前缀。
% 乘以 100 和作为百分比显示
? 乘以 1000 和作为千进制货币符显示;用货币符号代替;如果双写,用
国际货币符号代替。如果出现在一个模式中,用货币十进制分隔符代
替十进制分隔符。
X 前缀或后缀中使用的任何其它字符,用来引用前缀或后缀中的特殊字符。
例子:
DecimalFormat df1 = new DecimalFormat("0.0");
DecimalFormat df2 = new DecimalFormat("#.#");
DecimalFormat df3 = new DecimalFormat("000.000");
DecimalFormat df4 = new DecimalFormat("###.###");
System.out.println(df1.format(12.34));
System.out.println(df2.format(12.34));
System.out.println(df3.format(12.34));
System.out.println(df4.format(12.34));
结果:
12.3
12.3
012.340
12.34
json字符串参数的更多相关文章
- springMVC 接收json字符串参数
/** 前台js拼接了一个数组 myparam = [a,b,c]; 在ajax中直接 {"myparam":JSON.stringify(myparam)} 传入springMV ...
- springboot使用RestTemplate以post方式发送json字符串参数(以向钉钉机器人发送消息为例)
使用springboot之前,我们发送http消息是这么实现的 我们用了一个过时的类,虽然感觉有些不爽,但是出于一些原因,一直也没有做处理,最近公司项目框架改为了springboot,springbo ...
- api controller 接口接收json字符串参数
{"data":{"alarmRepeatTimes":2,"currentMode":1,"moduleResetTimeout ...
- httpclient工具类,post请求发送json字符串参数,中文乱码处理
在使用httpclient发送post请求的时候,接收端中文乱码问题解决. 正文: 我们都知道,一般情况下使用post请求是不会出现中文乱码的.可是在使用httpclient发送post请求报文含中文 ...
- @RequestBody接收ajax的json字符串
在使用ajax进行请求,并传递参数时,偶尔需要把数组作为传递参数,这是就要使用@RequestBody来解决这个问题 在页面端的处理: (1)利用JSON.stringify(arr)需要把json对 ...
- 大话Json对象和Json字符串
一.Json对象和Json字符串的区别 (1)Json对象:可以通过javascript存取属性. 先介绍一下json对象,首先说到对象的概念,对象的属性是可以用:对象.属性进行调用的.例如: var ...
- HttpClient 模拟发送Post和Get请求 并用fastjson对返回json字符串数据解析,和HttpClient一些参数方法的deprecated(弃用)的综合总结
最近在做一个接口调用的时候用到Apache的httpclient时候,发现引入最新版本4.5,DefaultHttpClient等老版本常用的类已经过时了,不推荐使用了:去官网看了一下在4.3之后就抛 ...
- 工具请求接口参数为string类型的JSON字符串时需要加转义字符模拟测试
例如postMan传String类型的json字符串请后台接口时,需要\转义
- 速战速决 (6) - PHP: 获取 http 请求数据, 获取 get 数据 和 post 数据, json 字符串与对象之间的相互转换
[源码下载] 速战速决 (6) - PHP: 获取 http 请求数据, 获取 get 数据 和 post 数据, json 字符串与对象之间的相互转换 作者:webabcd 介绍速战速决 之 PHP ...
随机推荐
- sql材料分级统计及汇总案例参考
--第一步:根据系统编号.列.单价分组求和 select CLBH,DJ,sum(SL) as SL,sum(JE) as JE,Lie into #TempSZCMX from #ShouZhiCu ...
- mvc4中jquery-ui日期控件datepicker的应用
mvc4中jquery-ui日期控件datepicker的应用 本文适合mvc中日期选择需要的同学: 假设读者已经具备了mvc4和javascript中的相关知识 一. 开始项目之前把项目中目录:/C ...
- C语言指针操作
欢迎访问我的新博客:http://www.milkcu.com/blog/ 原文地址:http://www.milkcu.com/blog/archives/pointer-manipulation. ...
- 笔试总结篇(一) : 广州X公司笔试
一.单选题: Ps : 当时由于去广州路上颠簸很困,导致刚做几分钟题目就睡了一觉.起来发现20分钟过去了.擦擦! 1. 假设磁盘文件foobar.txt 由 6个ASCII 码字符“foobar” 组 ...
- Windows使用SSH管理Ubuntu
欢迎访问我的新博客:http://www.milkcu.com/blog/ 原文地址:http://www.milkcu.com/blog/archives/manage-ubuntu-on-wind ...
- WinForm媒体播放器
媒体播放控件(Windows Media Player )的常用属性和方法,并且利用它设计一个简单的媒体应用程序——媒体播放器.该媒体播放器可以播放 wav.avi.mid 和 mp3 等格式的文件. ...
- Apache指南:CGI动态页面
概要 相关模块 相关指令 mod_alias mod_cgi AddHandler Options ScriptAlias CGI(公共网关接口[Common Gateway Interface])定 ...
- C#中鼠标划过按钮时候的提示信息
ToolTip p = new ToolTip(); p.ShowAlways = true; p.SetToolTip(this.Buton1, &quo ...
- xTree学习
1.XTREE简介: XTREE是一个基于AJAX实现的树形菜单.它的原理就是每次都只加载当前结点下的所有结点,而对开发人员来说,就是只需要按一定的格式,生成一段XML代码.XTREE可以自己定制每个 ...
- 调WScript.Shell时报错:Automation 服务器不能创建对象
我们经常需要通过生成ActiveXObject("WScript.Shell");来调某一exe文件, 如 //设置网页打印的页眉页脚为空 var HKEY_Root,HKEY_P ...