zoukankan      html  css  js  c++  java
  • 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);
    }

    ----------------------------------------------------------------------------------------------------------------------------------------------

    DecimalFormat 是 NumberFormat 的一个具体子类,用于格式化十进制数字。
     
    DecimalFormat 包含一个模式 和一组符号

      符号含义:
      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
    当能力支撑不了野心时,就该静下心来学习!
  • 相关阅读:
    HDU2149-Public Sale
    分页和多条件查询功能
    hdu 4691 最长的共同前缀 后缀数组 +lcp+rmq
    BZOJ 2588 Count on a tree (COT) 是持久的段树
    windows 设置脚本IP
    hdu 4912 Paths on the tree(树链拆分+贪婪)
    分散式-ubuntu12.04安装hadoop1.2.1
    struts详细解释拦截器
    Codeforces 459E Pashmak and Graph(dp+贪婪)
    C#中的数据格式转换 (未完待更新)
  • 原文地址:https://www.cnblogs.com/1234cjq/p/6089586.html
Copyright © 2011-2022 走看看