123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448 |
- package com.minpay.shouhuo;
- import com.minpay.common.bean.User;
- import com.minpay.common.format.IFormatService;
- import com.minpay.common.service.ILogService;
- import com.minpay.common.service.IPropertiesService;
- import com.minpay.common.util.CommonUtil;
- import com.minpay.common.util.DateUtil;
- import com.minpay.common.util.HttpPostUtil;
- import com.minpay.db.table.mapper.VmDeliveryInfMapper;
- import com.minpay.db.table.mapper.VmOrderDetailsMapper;
- import com.minpay.db.table.mapper.VmOrderInfMapper;
- import com.minpay.db.table.model.VmDeliveryInf;
- import com.minpay.db.table.model.VmOrderDetails;
- import com.minpay.db.table.model.VmOrderInf;
- import com.minpay.db.table.own.mapper.OrderManageMapper;
- import com.startup.minpay.frame.business.IMINAction;
- import com.startup.minpay.frame.business.res.MINActionResult;
- import com.startup.minpay.frame.constant.IMINBusinessConstant;
- import com.startup.minpay.frame.data.format.MINCopyFormat;
- import com.startup.minpay.frame.exception.MINBusinessException;
- import com.startup.minpay.frame.jdbc.MINRowBounds;
- import com.startup.minpay.frame.service.base.IMINDataBaseService;
- import com.startup.minpay.frame.service.base.Service;
- import com.startup.minpay.frame.session.MINSession;
- import com.startup.minpay.frame.target.MINAction;
- import com.startup.minpay.frame.target.MINComponent;
- import com.startup.minpay.frame.target.MINParam;
- import net.sf.json.JSONObject;
- import org.apache.commons.lang.StringUtils;
- import java.math.BigDecimal;
- import java.text.SimpleDateFormat;
- import java.util.*;
- /**
- * 财务管理
- *
- * @author wlm
- */
- @MINComponent
- public class invCardManageAction implements IMINAction {
- /**查询订单详情**/
- public final static String SELECT_ORDER_DETAIL = "selectOrderDetail";
- /**取货、作废**/
- public final static String UPDATE_ORDER_STT = "updateOrderStt";
- /**查询取货记录**/
- public final static String SELECT_PICKUP_RECORD = "selectPickupRecord";
- /** 收入统计 **/
- public final static String SELECT_INCOME_STATISTICS = "selectIncomeStatistics";
- /** 收入统计 **/
- public final static String SELECT_ALL_INCOME = "selectAllIncome";
- /** 销售数据 **/
- public final static String SELECT_SALES_DATA = "selectSalesData";
- /** 销售数据2 **/
- public final static String SELECT_ALL_SALE = "selectAllSale";
- /** 时间轴查询销售金额、预估利润 **/
- public final static String SELECT_INCOME_BYDATE = "selectIncomeBydate";
- /**
- * 时间轴查询销售金额、预估利润
- * @param session
- * @return
- * @throws Exception
- */
- @MINAction(value = SELECT_INCOME_BYDATE)
- public MINActionResult selectIncomeBydate (
- @MINParam(key = "dateFlag") String dateFlag,
- MINSession session) throws Exception {
- MINActionResult res = new MINActionResult();
- User user = session.getUser();
- //获取当前时间
- Date currentTime = new Date();
- String nowDate = DateUtil.format(currentTime,"yyyyMMdd");
- Map<String, String> m = new HashMap<String, String>();
- //昨天
- String yesDate = DateUtil.getDifferentDate(-1).substring(0,8);
- //本周第一天
- Calendar cal=Calendar.getInstance();
- cal.add(Calendar.WEEK_OF_MONTH, 0);
- cal.set(Calendar.DAY_OF_WEEK, 2);
- Date weekFristDate = cal.getTime();
- String weekDate = DateUtil.format(weekFristDate,"yyyyMMdd");
- //按时间查询
- String time = null;
- if("0".equals(dateFlag)) {
- m.put("nowDate", nowDate);
- Date parse = new SimpleDateFormat("yyyyMMdd").parse(nowDate);
- String dateString = new SimpleDateFormat("yyyy-MM-dd").format(parse);
- time = dateString;
- }else if("1".equals(dateFlag)) {
- m.put("yesDate", yesDate);
- Date parse = new SimpleDateFormat("yyyyMMdd").parse(yesDate);
- String dateString = new SimpleDateFormat("yyyy-MM-dd").format(parse);
- time = dateString;
- }else if("2".equals(dateFlag)) {
- m.put("weekDate", weekDate);
- Date parse = new SimpleDateFormat("yyyyMMdd").parse(weekDate);
- String dateString = new SimpleDateFormat("yyyy-MM-dd").format(parse);
- Date parseb = new SimpleDateFormat("yyyyMMdd").parse(nowDate);
- String dateStringb = new SimpleDateFormat("yyyy-MM-dd").format(parseb);
- time = dateString.concat(" 至 ").concat(dateStringb);
- }
- //查询累计收入
- String countIncome = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(OrderManageMapper.class).selectCountIncome(m);
- //查询总成本价
- String predictIncome = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(OrderManageMapper.class).selectPredictIncome(m);
- //查询累计收入
- List<Map<String, String>> mapList = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(OrderManageMapper.class).selectCountIncomeb(m);
- String wxzfbAmout = "0";
- String czAmout = "0";
- for (int i = 0; i < mapList.size(); i++) {
- Map<String, String> map = mapList.get(i);
- String transType = map.get("transType");
- if(transType.equals("00")){ //充值金额
- czAmout = String.valueOf(map.get("amout"));
- }
- if(transType.equals("10")){ //支付金额
- wxzfbAmout = String.valueOf(map.get("amout"));
- }
- }
- predictIncome = CommonUtil.subtract(countIncome,predictIncome);
- String zsrAmout = CommonUtil.add(czAmout,wxzfbAmout);
- //返回数据
- res.set("countIncome", countIncome);
- res.set("predictIncome", predictIncome);
- res.set("czAmout", czAmout);
- res.set("zsrAmout", zsrAmout);
- res.set("time", time);
- return res;
- }
- /**
- * 总销售数量
- * @param session
- * @return
- * @throws Exception
- */
- @MINAction(value = SELECT_ALL_SALE)
- public MINActionResult selectAllSale (
- MINSession session) throws Exception {
- MINActionResult res = new MINActionResult();
- User user = session.getUser();
- //总实际金额
- String allSale = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(OrderManageMapper.class).selectAllSale();
- //总商品成本
- String allCost = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(OrderManageMapper.class).selectAllCost();
- BigDecimal num1 = new BigDecimal(allSale);
- BigDecimal num2 = new BigDecimal(allCost);
- BigDecimal allProfit = num1.subtract(num2);
- //返回数据
- res.set("allSale", allSale);
- res.set("allCost", allCost);
- res.set("allProfit", allProfit);
- return res;
- }
- /**
- * 销售数据
- * @param page
- * @param limit
- * @param session
- * @return
- * @throws Exception
- */
- @MINAction(value = SELECT_SALES_DATA)
- public MINActionResult selectSalesData (
- @MINParam(key = "page", defaultValue = "1") int page,
- @MINParam(key = "limit", defaultValue = "7") int limit,
- @MINParam(key = "proName") String proName,
- MINSession session) throws Exception {
- MINActionResult res = new MINActionResult();
- User user = session.getUser();
- Map<String, String> m = new HashMap<String, String>();
- m.put("proName", proName);
- MINRowBounds rows = new MINRowBounds(page, limit);
- List<Map<String, String>> detailList = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(OrderManageMapper.class).selectProductInfo(rows, m);
- detailList = Service.lookup(IFormatService.class).formatCurrency(detailList, "amount", "proNums");
- //返回数据
- res.set(IMINBusinessConstant.F_PAGING_LAY, detailList);
- res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getCount());
- return res;
- }
- /**
- * 总收入统计
- * @param session
- * @return
- * @throws Exception
- */
- // @MINAction(value = SELECT_ALL_INCOME)
- // public MINActionResult selectAllIncome (
- // MINSession session) throws Exception {
- // MINActionResult res = new MINActionResult();
- // User user = session.getUser();
- // //查询订单数
- // String orderNum = Service.lookup(IMINDataBaseService.class)
- // .getMybatisMapper(OrderManageMapper.class).selectCountOrderNum();
- // //查询累计收入
- // String countIncome = Service.lookup(IMINDataBaseService.class)
- // .getMybatisMapper(OrderManageMapper.class).selectCountIncome();
- // //查询总机台数
- // String countDevice = Service.lookup(IMINDataBaseService.class)
- // .getMybatisMapper(OrderManageMapper.class).selectCountDevice();
- // //返回数据
- // res.set("orderNum", orderNum);
- // res.set("countIncome", countIncome);
- // res.set("countDevice", countDevice);
- // return res;
- // }
- /**
- * 收入统计
- * @param page
- * @param limit
- * @param session
- * @return
- * @throws Exception
- */
- @MINAction(value = SELECT_INCOME_STATISTICS)
- public MINActionResult selectIncomeStatistics (
- @MINParam(key = "page", defaultValue = "1") int page,
- @MINParam(key = "limit", defaultValue = "10") int limit,
- @MINParam(key = "equNum") String equNum,
- @MINParam(key = "datesTime") String datesTime,
- MINSession session) throws Exception {
- MINActionResult res = new MINActionResult();
- User user = session.getUser();
- String branchId = user.getBranchId();
- MINRowBounds rows = new MINRowBounds(page, limit);
- //获取当前时间
- Date currentTime = new Date();
- String nowDate = DateUtil.format(currentTime,"yyyyMMdd");
- Map<String, String> m = new HashMap<String, String>();
- m.put("equNum", equNum);
- m.put("datesTime", datesTime);
- m.put("nowDate", nowDate);
- if(!"88888888".equals(branchId)) {
- m.put("branchId", branchId);
- }
- List<Map<String, String>> detailList = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(OrderManageMapper.class).selectIncomeDetail(rows, m);
- detailList = Service.lookup(IFormatService.class).formatDate(detailList, "sellTime");
- detailList = Service.lookup(IFormatService.class).formatCurrency(detailList, "sellWxSum", "sellZfSum", "" +
- "sellMfSum", "allSell");
- //返回数据
- res.set(IMINBusinessConstant.F_PAGING_LAY, detailList);
- res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getCount());
- return res;
- }
- /**
- * 取货记录
- * @param machineNo
- * @param orderNo
- * @param pickUpDates
- * @param page
- * @param limit
- * @param session
- * @return
- * @throws Exception
- */
- @MINAction(value = SELECT_PICKUP_RECORD)
- public MINActionResult selectPickupRecord (
- @MINParam(key = "machineNo") String machineNo,
- @MINParam(key = "orderNo") String orderNo,
- @MINParam(key = "pickUpDates") String pickUpDates,
- @MINParam(key = "equrelId") String equrelId,
- @MINParam(key = "vciId") String vciId,
- @MINParam(key = "pickupNo") String pickupNo,
- @MINParam(key = "page", defaultValue = "1") int page,
- @MINParam(key = "limit", defaultValue = "3") int limit,
- MINSession session) throws Exception {
- MINActionResult res = new MINActionResult();
- User user = session.getUser();
- String branchId = user.getBranchId();
- Map<String, String> m = new HashMap<String, String>();
- m.put("machineNo", machineNo);
- m.put("orderNo", orderNo);
- m.put("pickUpDates", pickUpDates);
- m.put("equrelId", equrelId);
- m.put("vciId", vciId);
- m.put("pickupNo", pickupNo);
- if(!"88888888".equals(branchId)) {
- m.put("branchId", branchId);
- }
- MINRowBounds rows = new MINRowBounds(page, limit);
- List<Map<String, String>> detailList = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(OrderManageMapper.class).selectPickupRecord(m,rows);
- detailList = new MINCopyFormat("{stt:'sttDesc'}").format(detailList);
- detailList = Service.lookup(IFormatService.class).formatEnum(detailList,"{sttDesc:'PICKUP_STT'}");
- detailList = Service.lookup(IFormatService.class).formatDateTime(detailList, "pickUpTime");
- //返回数据
- res.set(IMINBusinessConstant.F_PAGING_LAY, detailList);
- res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getCount());
- return res;
- }
- /**
- * 查询订单详情
- * @param machineNo
- * @param pickUpCode
- * @param creatdDtes
- * @param pickUpDates
- * @param pickUpState
- * @param page
- * @param limit
- * @param session
- * @return
- * @throws Exception
- */
- @MINAction(value = SELECT_ORDER_DETAIL)
- public MINActionResult selectOrderDetail (
- @MINParam(key = "machineNo") String machineNo,
- @MINParam(key = "pickUpCode") String pickUpCode,
- @MINParam(key = "equrelId") String equrelId,
- @MINParam(key = "creatdDtes") String creatdDtes,
- @MINParam(key = "pickUpDates") String pickUpDates,
- @MINParam(key = "pickUpState") String pickUpState,
- @MINParam(key = "page", defaultValue = "1") int page,
- @MINParam(key = "limit", defaultValue = "3") int limit,
- MINSession session) throws Exception {
- MINActionResult res = new MINActionResult();
- User user = session.getUser();
- String branchId = user.getBranchId();
- Map<String, String> m = new HashMap<String, String>();
- m.put("machineNo", machineNo);
- m.put("pickUpCode", pickUpCode);
- m.put("equrelId", equrelId);
- m.put("creatdDtes", creatdDtes);
- m.put("pickUpDates", pickUpDates);
- m.put("pickUpState", pickUpState);
- if(!"88888888".equals(branchId)) {
- m.put("branchId", branchId);
- }
- MINRowBounds rows = new MINRowBounds(page, limit);
- List<Map<String, String>> detailList = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(OrderManageMapper.class).selectOrderDetail(m,rows);
- // 格式化数据
- detailList = Service.lookup(IFormatService.class).formatDateTime(detailList, "pickUpTime");
- detailList = Service.lookup(IFormatService.class).formatDateTime(detailList, "createTime");
- detailList = new MINCopyFormat("{stt:'sttDesc'}").format(detailList);
- detailList = Service.lookup(IFormatService.class).formatEnum(detailList,"{sttDesc:'ORDER_PICKUP_STT'}");
- //返回数据
- res.set(IMINBusinessConstant.F_PAGING_LAY, detailList);
- res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getMaxRows());
- return res;
- }
- /**
- *卡卷管理、取货、作废
- * @param orderNo
- * @param temp 操作0:作废,1:取货
- * @param session
- * @return
- * @throws Exception
- */
- @MINAction(value = UPDATE_ORDER_STT)
- public MINActionResult updateOrderStt(
- @MINParam ( key = "orderNo")String orderNo,
- @MINParam ( key = "temp")String temp,
- @MINParam ( key = "pickupNo")String pickupNo,
- @MINParam ( key = "detailsId")String detailsId,
- MINSession session) throws Exception{
- MINActionResult res = new MINActionResult();
- User user = session.getUser();
- VmDeliveryInf vd = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmDeliveryInfMapper.class)
- .selectByPrimaryKey(pickupNo);
- if(vd == null || "2".equals(vd.getStatus()) || "6".equals(vd.getStatus())){
- throw new MINBusinessException("提货编号已提货");
- }
- String ordDetId = vd.getOrdDetId();
- VmOrderDetails vmOrderDetails = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmOrderDetailsMapper.class)
- .selectByPrimaryKey(ordDetId);
- if(vmOrderDetails == null||"01".equals(vmOrderDetails.getIsDelivery())){
- throw new MINBusinessException("提货编号已提货");
- }
- String info = "";
- if ("0".equals(temp)) {
- vd.setStatus("6");
- info = "废止";
- //修改提货表
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmDeliveryInfMapper.class)
- .updateByPrimaryKeySelective(vd);
- //修改订单详情表
- vmOrderDetails.setIsDelivery("01");
- vmOrderDetails.setPickupTime(DateUtil.getCurrentDateTimeString());
- Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmOrderDetailsMapper.class)
- .updateByPrimaryKeySelective(vmOrderDetails);
- }else if("1".equals(temp)) {
- String url = Service.lookup(IPropertiesService.class)
- .getSystemProperties().get("V01_SHOUHUO_NOTIFY_URL").getKey();
- StringBuffer paramStr = new StringBuffer();
- paramStr.append("MINView=JSON&");
- paramStr.append("deliveryNo=");
- paramStr.append(pickupNo);
- url = url.concat("/DeliveryAction/makeDeliveryForMachineNoSession?");
- String jsonObj = HttpPostUtil.sendPost(url, paramStr.toString());
- if(CommonUtil.isEmpty(jsonObj)){
- throw new MINBusinessException("操作失败!请重新操作");
- }
- JSONObject js2 = JSONObject.fromObject(jsonObj);
- String mINStatus = js2.getString("MINStatus");
- String mINErrorMessage = js2.getString("MINErrorMessage");
- //{"msg":"没有提货信息!","code":1,"MINPage":{"charset":"UTF-8","cache":false,"view":"JSON","page":"","type":"","contentType":"text/html"},"MINLangLocale":"zh_CN","MINStatus":1,"MINTime":"2020-12-13 01:41:56","MINErrorMessage":"没有提货信息!"}
- if(!"0".equals(mINStatus)){
- throw new MINBusinessException(mINErrorMessage);
- }
- //发送请求
- info = "发货";
- }
- //日志
- String logInfo = user.getName()+"-更新提货单状态:" +info+ ",订单号"+pickupNo;
- Service.lookup(ILogService.class).logging(session, logInfo);
- return res;
- }
- }
|