| | |
| | | package com.yeshi.fanli.controller.admin;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
| | | import com.google.gson.reflect.TypeToken;
|
| | | import com.yeshi.fanli.controller.admin.utils.AdminUtils;
|
| | | import com.yeshi.fanli.entity.admin.OrderAdmin;
|
| | | import com.yeshi.fanli.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderCountService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.vo.order.CommonOrderVO;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("admin/new/api/v1/order")
|
| | |
| | |
|
| | | @Resource
|
| | | private CommonOrderCountService commonOrderCountService;
|
| | | |
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | | |
| | |
|
| | | @RequestMapping(value = "getOrderList", method = RequestMethod.POST)
|
| | | public void getOrderList(int pageIndex, String key, PrintWriter out) {
|
| | |
| | | data.put("orderList", JsonUtil.getSimpleGsonWithDateAndSerialization().toJson(orderAdminList));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @RequestMapping(value = "getHistoryOrder")
|
| | | public void getHistoryOrder(String callback, Integer pageIndex, Integer pageSize, Long uid, Integer state, Integer type, |
| | | Integer orderState, String orderNo, String startTime, String endTime, PrintWriter out) {
|
| | |
|
| | | if (uid == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("uid不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (pageIndex == null || pageIndex < 1) {
|
| | | pageIndex = 1;
|
| | | }
|
| | | |
| | | if (pageSize == null)
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | |
|
| | | if (state != null && state == 0) {
|
| | | state = null;// 所有状态
|
| | | }
|
| | |
|
| | | if (type != null && type == 0) {
|
| | | type = null; // 所有类型订单
|
| | | }
|
| | |
|
| | | try {
|
| | | long count = 0;
|
| | |
|
| | | // 查询列表
|
| | | List<CommonOrderVO> list = commonOrderService.listQueryByUid((pageIndex - 1) * pageSize, pageSize , |
| | | uid, state, type, orderState, orderNo, startTime, endTime, null);
|
| | |
|
| | | if (list != null && list.size() > 0) {
|
| | | // 统计总数
|
| | | count = commonOrderService.countQueryByUid(uid, state, type, orderState, orderNo, startTime,
|
| | | endTime, null);
|
| | | }
|
| | | |
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("result_list", list);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (CommonOrderException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 统计历史渠道产生订单的金额
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | |
| | | private CommonOrderService commonOrderService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoService hongBaoService;
|
| | | private HongBaoV2CountService hongBaoV2CountService;
|
| | |
|
| | | /**
|
| | | * 订单列表
|
| | |
| | |
|
| | | try {
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | // 分享统计
|
| | | BigDecimal sharemoney = commonOrderService.countBonusOrderMoney(uid,2, dateType, null, null);
|
| | | Object shareCount = 0;
|
| | | BigDecimal sharemoney = new BigDecimal(0.00);
|
| | | Object inviteCount = 0;
|
| | | BigDecimal inviteMoney = new BigDecimal(0.00);
|
| | |
|
| | | data.put("shareCount", commonOrderService.countBonusOrderNumber(uid, 2, dateType, null, null));
|
| | | data.put("sharemoney", sharemoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | Map<String, Object> shareMap = commonOrderService.countBonusOrderMoneyAndNumber(uid, 2 , dateType, null, null);
|
| | | if (shareMap != null) {
|
| | | Object totalNum = shareMap.get("totalNum");
|
| | | if (totalNum != null) {
|
| | | shareCount = totalNum;
|
| | | }
|
| | | |
| | | Object totalmoney = shareMap.get("totalmoney");
|
| | | if (totalmoney != null) {
|
| | | sharemoney = (BigDecimal) totalmoney;
|
| | | sharemoney = sharemoney.setScale(2, BigDecimal.ROUND_DOWN);
|
| | | }
|
| | | }
|
| | |
|
| | | // 邀请统计
|
| | | BigDecimal inviteMoney = commonOrderService.countBonusOrderMoney(uid,3, dateType, null, null);
|
| | | Map<String, Object> inviteMap = commonOrderService.countBonusOrderMoneyAndNumber(uid, 3 , dateType, null, null);
|
| | | if (inviteMap != null) {
|
| | | Object totalNum = inviteMap.get("totalNum");
|
| | | if (totalNum != null) {
|
| | | inviteCount = totalNum;
|
| | | }
|
| | | |
| | | Object totalmoney = inviteMap.get("totalmoney");
|
| | | if (totalmoney != null) {
|
| | | sharemoney = (BigDecimal) totalmoney;
|
| | | inviteMoney = sharemoney.setScale(2, BigDecimal.ROUND_DOWN);
|
| | | }
|
| | | }
|
| | |
|
| | | data.put("inviteCount", commonOrderService.countBonusOrderNumber(uid, 3, dateType, null, null));
|
| | | data.put("inviteMoney", inviteMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | |
|
| | | data.put("showTiCheng", hongBaoService.getTotalTiChengCount(uid) > 0);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("shareCount", shareCount);
|
| | | data.put("sharemoney", sharemoney);
|
| | | data.put("inviteCount", inviteCount);
|
| | | data.put("inviteMoney", inviteMoney);
|
| | |
|
| | | data.put("showTiCheng", hongBaoV2CountService.getTotalTiChengCount(uid) > 0);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | |
| | | List<Map<String, Object>> countHongBaoTotalNum(@Param("dateType")Integer dateType, @Param("year") String year, |
| | | @Param("startTime")String startTime, @Param("endTime")String endTime); |
| | | |
| | | |
| | | // 累计提成订单数量(包含无效订单) |
| | | int getTotalTiChengCount(Long uid); |
| | | } |
| | |
| | | BigDecimal countBonusOrderMoney(@Param("uid") Long uid, @Param("type") Integer type, @Param("day") Integer day, |
| | | @Param("startTime") String startTime, @Param("endTime") String endTime); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 奖金统计 |
| | | * |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | Map<String, Object> countBonusOrderMoneyAndNumber(@Param("uid")Long uid, @Param("type")Integer type, |
| | | @Param("day")Integer day, @Param("startTime")String startTime, @Param("endTime")String endTime); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | int countByOrderNOAndOrderType(@Param("orderNO") String orderNO, @Param("orderType") int orderType); |
| | | |
| | |
| | | </select> |
| | | |
| | | |
| | | <select id="getTotalTiChengCount" resultType="java.lang.Integer" parameterType="java.lang.Long"> |
| | | SELECT count(*) FROM `yeshi_ec_hongbao_v2` h |
| | | WHERE h.`hb_uid`=#{0} |
| | | AND (h.`hb_type`=20 OR h.`hb_type`=21 OR h.`hb_type`=22 OR h.`hb_type`=6 OR h.`hb_type`=7) |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | resultMap="com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper.BaseResultMap"> |
| | | </association> |
| | | |
| | | |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List">co_id,co_uid,co_order_no,co_source_type,co_source_position,co_order_goods_id,co_count,co_state,co_state_whole_order,co_estimate,co_eIncome,co_payment,co_settlement,co_third_create_time,co_settle_time,co_order_by,co_create_time,co_update_time |
| | |
| | | |
| | | <sql id="SELECT_PARAM_ORDER_STATE"> |
| | | <if test="orderState != null and orderState == 1"> |
| | | <!-- 有效订单: 整个订单有效、 部分订单有效 --> |
| | | <!-- 有效订单: 整个订单有效 --> |
| | | AND <![CDATA[co.`co_state` <> 3]]> AND (co.co_state_whole_order = 1 or co.co_state_whole_order = 2) |
| | | </if> |
| | | <if test="orderState != null and orderState == 2"> |
| | |
| | | </sql> |
| | | |
| | | <sql id="SELECT_PARAM_ORDER_CREATE_TIME"> |
| | | <if test="startTime != null"> |
| | | <if test="startTime != null and startTime != '' "> |
| | | AND <![CDATA[co.co_create_time >= #{startTime}]]> |
| | | </if> |
| | | <if test="endTime != null"> |
| | | <if test="endTime != null and endTime != '' "> |
| | | AND <![CDATA[co.co_create_time <= #{endTime}]]> |
| | | </if> |
| | | <if test="day != null and day == 1"> <!-- 今天 --> |
| | |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="countBonusOrderMoneyAndNumber" resultType="java.util.HashMap"> |
| | | <!-- 奖金统计:订单总返利金额 去掉已失效 --> |
| | | SELECT COUNT(ho.`ho_id`) AS totalNum, |
| | | CAST(SUM(IF(hb.hb_id IS NULL,hbp.`hb_money`,hb.`hb_money`))AS DECIMAL(19,2)) AS totalmoney |
| | | FROM yeshi_ec_hongbao_order ho |
| | | LEFT JOIN ( |
| | | SELECT * FROM yeshi_ec_hongbao_v2 v2 |
| | | WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" /> |
| | | AND (v2.hb_state = 1 or v2.hb_state = 2 or v2.hb_state = 3) |
| | | ) hb ON hb.hb_id=ho.`ho_hongbao_id` |
| | | LEFT JOIN ( |
| | | SELECT * FROM yeshi_ec_hongbao_v2 v2 |
| | | WHERE v2.`hb_uid`=${uid} <include refid="SELECT_PARAM_HONGBAO_TYPE" /> |
| | | AND (v2.hb_state = 1 or v2.hb_state = 2 or v2.hb_state = 3) |
| | | ) hbp ON hbp.hb_pid=ho.`ho_hongbao_id` |
| | | LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` |
| | | WHERE (hb.hb_id IS NOT NULL OR hbp.hb_id IS NOT NULL) |
| | | <include refid="SELECT_PARAM_ORDER_CREATE_TIME" /> |
| | | <if test="day != null and day == 4"> |
| | | AND co.`co_state` = 2 <!-- 上月 :统计已收货 --> |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="listQueryByUid" resultMap="ResultMap"> |
| | | <!-- 查询用户订单 --> |
| | | SELECT IF(hb.hb_id IS NULL,hbp.`hb_money`,hb.`hb_money`) AS totalMoney, |
| | |
| | | IF(hb.hb_id IS NULL,hbp.`hb_type`,hb.`hb_type`) AS hongBaoType, |
| | | IF(hb.hb_id IS NULL,hbp.`hb_get_time`,hb.`hb_get_time`) AS accountTime, |
| | | IF(hb.hb_id IS NULL,hbp.`hb_pre_get_time`,hb.`hb_pre_get_time`) AS preAccountTime, |
| | | co.* |
| | | co.*,cog.* |
| | | FROM yeshi_ec_hongbao_order ho |
| | | |
| | | LEFT JOIN (SELECT * FROM yeshi_ec_hongbao_v2 v2 |
| | |
| | | )hbp ON hbp.hb_pid=ho.`ho_hongbao_id` |
| | | |
| | | LEFT JOIN yeshi_ec_common_order co ON co.`co_id`=ho.`ho_order_id` |
| | | LEFT JOIN yeshi_ec_common_order_goods cog ON cog.`cog_id`= co.`co_order_goods_id` |
| | | WHERE (hb.hb_id IS NOT NULL OR hbp.hb_id IS NOT NULL) |
| | | <include refid="SELECT_PARAM_ORDER_STATE"/> <!-- 订单状态 --> |
| | | <include refid="SELECT_PARAM_ORDER_CREATE_TIME"/> <!-- 订单时间 --> |
| | |
| | | return hongBaoV2CountMapper.countNumberByUidAndState(uid, state);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public int getTotalTiChengCount(Long uid) {
|
| | | return hongBaoV2CountMapper.getTotalTiChengCount(uid);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | public BigDecimal countBonusOrderMoney(Long uid, Integer type, Integer day, String startTime, String endTime) {
|
| | | return commonOrderMapper.countBonusOrderMoney(uid, type, day, startTime, endTime);
|
| | | }
|
| | | |
| | | @Override
|
| | | public Map<String, Object> countBonusOrderMoneyAndNumber(Long uid, Integer type, Integer day, |
| | | String startTime, String endTime) {
|
| | | return commonOrderMapper.countBonusOrderMoneyAndNumber(uid, type, day, startTime, endTime);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Map<String, BigDecimal> countByUidAndOrderState(Long uid, Integer type, String startTime, String endTime,
|
| | |
| | | if (list.size() == 0) {
|
| | | return list;
|
| | | }
|
| | |
|
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
| | | for (CommonOrderVO order : list) {
|
| | | |
| | | // 下单时间
|
| | | Date thirdCreateTime = order.getThirdCreateTime();
|
| | | if (thirdCreateTime != null) {
|
| | | order.setDownTime(format.format(thirdCreateTime));
|
| | | }
|
| | | // 收货时间
|
| | | Date settleTime = order.getSettleTime();
|
| | | if (settleTime != null) {
|
| | | order.setReceiveTime(format.format(settleTime));
|
| | | }
|
| | | |
| | | // 到账时间
|
| | | Date accountTime = order.getAccountTime();
|
| | | if (accountTime != null) {
|
| | | order.setHongBaoDate(format.format(accountTime));
|
| | | }
|
| | | |
| | | BigDecimal settlement = order.getSettlement();
|
| | | if (settlement != null && settlement.compareTo(new BigDecimal(0)) > 0) {
|
| | | order.setPayment(settlement); // 实际付款金额
|
| | | }
|
| | |
|
| | | /* 订单返利类型 转换 */
|
| | | Integer hongBaoType = order.getHongBaoType();
|
| | |
| | | // 已失效
|
| | | order.setHongBaoState(3);
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | | return list;
|
| | |
| | | */
|
| | | public List<Map<String, Object>> getProportionByType(Integer dateType, Integer type, String year, String startTime,
|
| | | String endTime) throws Exception;
|
| | |
|
| | | /**
|
| | | * 统计提成订单数量
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public int getTotalTiChengCount(Long uid);
|
| | |
|
| | |
|
| | |
|
| | |
| | | public BigDecimal countBonusOrderMoney(Long uid, Integer type, Integer isToday, String startTime, String endTime);
|
| | |
|
| | | /**
|
| | | * 统计奖金订单数量、金额
|
| | | * @param uid
|
| | | * @param type
|
| | | * @param day
|
| | | * @param startTime
|
| | | * @param endTime
|
| | | * @return
|
| | | */
|
| | | public Map<String, Object> countBonusOrderMoneyAndNumber(Long uid, Integer type, Integer day, String startTime,
|
| | | String endTime);
|
| | |
|
| | | |
| | | /**
|
| | | * 根据条件统计
|
| | | *
|
| | | * @param uid
|