Authored by caoyan

Merge branch 'master' of http://git.yoho.cn/ufo/ufo-platform

... ... @@ -53,7 +53,7 @@ public class LoginController {
session.setAttribute(PlatformConstant.USER_SESSION, responseBO.getData());
//获取用户所能见的菜单
Response<Map<String, List<MenuInfoResponseBO>>> menuResp = loginService.getUserMenu(responseBO.getData().getPid(), responseBO.getData().getRole_id(), "5");
Response<Map<String, List<MenuInfoResponseBO>>> menuResp = loginService.getUserMenu(responseBO.getData().getPid(), responseBO.getData().getRole_id(), "7");
//存入session
session.setAttribute(PlatformConstant.USER_MENU, menuResp.getData());
... ...
... ... @@ -139,6 +139,8 @@ public class UploadServiceImpl implements IUploadService {
fileMode = "0" + (new Random().nextInt(2) + 1);
}
logger.info("upload image bucket is {}, fileMode is {}", bucket, fileMode);
String saveName = new SimpleDateFormat("/yyyy/MM/dd/HH/").format(new Date());
String fileName = fileMode
+ DigestUtils.md5Hex(uid + "_" + System.currentTimeMillis() + multipartFile.getOriginalFilename())
... ...
package com.yoho.order.dal;
import com.yoho.order.model.TradeBillsReq;
import com.yoho.order.model.TradeBills;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Created by craig.qin on 2018/9/12.
*/
public interface TradeBillsMapper {
int selectCountByCondition(@Param("billsTradeReq") TradeBillsReq req);
List<TradeBills> selectByConditionWithPage(@Param("billsTradeReq") TradeBillsReq req);
}
... ...
package com.yoho.order.model;
import lombok.Data;
import java.math.BigDecimal;
/**
* 交易流水表
*/
@Data
public class TradeBills {
private Integer id;
private Integer uid;
private Long orderCode;
//1:买家uid; 2:卖家uid
private Integer userType;
//1:支付宝; 2:微信
private Integer payType;
//1:保证金;2:货款;3:补偿款
private Integer tradeType;
//1:用户收入; 2:用户支出
private Integer incomeOutcome;
private BigDecimal amount;
//yoho收入
private BigDecimal systemAmount;
//0:订单未完结;1:订单完结
private Integer tradeStatus;
private Integer createTime;
//手工打款相关字段
//操作员id
private Integer dealUid;
//操作员名字,存储起来,展示的时候用
private String dealUserName;
//打款状态:1 表示成功, 现在只有成功的才记录
private Integer dealStatus;
//打款时间
private Integer dealTime;
//打款关联id
private Integer dealRelateId;
@Override
public String toString() {
return "TradeBills{" +
"id=" + id +
", uid=" + uid +
", orderCode=" + orderCode +
", userType=" + userType +
", payType=" + payType +
", tradeType=" + tradeType +
", incomeOutcome=" + incomeOutcome +
", amount=" + amount +
", systemAmount=" + systemAmount +
", tradeStatus=" + tradeStatus +
", createTime=" + createTime +
", dealUid=" + dealUid +
", dealUserName='" + dealUserName + '\'' +
", dealStatus=" + dealStatus +
", dealTime=" + dealTime +
", dealRelateId=" + dealRelateId +
'}';
}
}
... ...
package com.yoho.order.model;
import com.yoho.ufo.service.model.PageRequestBO;
import java.util.List;
/**
* Created by craig.qin.
*/
public class TradeBillsReq extends PageRequestBO{
/**
*
*/
private static final long serialVersionUID = 1620427808531296022L;
private Integer id;
private Long orderCode;
private Integer uid;
private String mobile;
///// status 并不是表里面的字段,是查询条件:全部、交易正常的订单、交易异常的订单
private Integer status;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Long getOrderCode() {
return orderCode;
}
public void setOrderCode(Long orderCode) {
this.orderCode = orderCode;
}
public Integer getUid() {
return uid;
}
public void setUid(Integer uid) {
this.uid = uid;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
@Override
public String toString() {
return "TradeBillsReq{" +
"id=" + id +
", orderCode=" + orderCode +
", uid=" + uid +
", mobile='" + mobile + '\'' +
", status=" + status +
'}';
}
}
... ...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yoho.order.dal.TradeBillsMapper">
<resultMap id="BaseResultMap" type="com.yoho.order.model.TradeBills">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="uid" jdbcType="INTEGER" property="uid" />
<result column="order_code" jdbcType="BIGINT" property="orderCode" />
<result column="user_type" jdbcType="TINYINT" property="userType" />
<result column="pay_type" jdbcType="TINYINT" property="payType" />
<result column="trade_type" jdbcType="INTEGER" property="tradeType" />
<result column="income_outcome" jdbcType="TINYINT" property="incomeOutcome" />
<result column="amount" jdbcType="DECIMAL" property="amount" />
<result column="system_amount" jdbcType="DECIMAL" property="systemAmount" />
<result column="trade_status" jdbcType="TINYINT" property="tradeStatus" />
<result column="create_time" jdbcType="INTEGER" property="createTime" />
<result column="deal_uid" jdbcType="INTEGER" property="dealUid" />
<result column="deal_status" jdbcType="TINYINT" property="dealStatus" />
<result column="deal_time" jdbcType="INTEGER" property="dealTime" />
<result column="deal_relate_id" jdbcType="INTEGER" property="dealRelateId" />
<result column="deal_user_name" jdbcType="VARCHAR" property="dealUserName" />
</resultMap>
<sql id="Base_Column_List">
id,uid, order_code, user_type,pay_type,trade_type,
income_outcome,amount,system_amount,trade_status,create_time,
deal_uid,deal_status,deal_time,deal_relate_id,deal_user_name
</sql>
<sql id="Query_Condition_Sql" >
<if test="billsTradeReq.orderCode != null">
and order_code = #{billsTradeReq.orderCode}
</if>
<if test="billsTradeReq.uid != null">
and uid = #{billsTradeReq.uid}
</if>
<if test="billsTradeReq.status != null ">
<choose>
<when test="billsTradeReq.status == 100 ">
and trade_status = 100
</when>
<otherwise>
and trade_status != 100 and deal_status != 1
</otherwise>
</choose>
</if>
</sql>
<select id="selectCountByCondition" resultType="java.lang.Integer" parameterType="com.yoho.order.model.BuyerOrderReq">
select count(id)
from trade_bills where 1=1
<include refid="Query_Condition_Sql" />
</select>
<select id="selectByConditionWithPage" resultMap="BaseResultMap" parameterType="com.yoho.order.model.TradeBillsReq">
select <include refid="Base_Column_List" />
from trade_bills where 1=1
<include refid="Query_Condition_Sql" />
limit #{billsTradeReq.start},#{billsTradeReq.size}
</select>
</mapper>
\ No newline at end of file
... ...
package com.yoho.ufo.order.constant;
/**
* 交易流水表
* 100:成功;200:失败,201:没有支付宝账号;202:金额不合法;299:转账失败
*/
public enum TradeStatusEnum {
success(100,"成功"),
fail_201_no_alipayAccount(201,"没有支付宝账号"),
fail_202_invalid_money(202,"金额不合法"),
fail_299_transfer_failure(299,"转账失败");
private Integer code;
private String desc;
TradeStatusEnum(Integer code,String desc){
this.code = code;
this.desc = desc;
}
public static String getDescByCode(Integer code){
if(code==null){
return "";
}
for(TradeStatusEnum item:TradeStatusEnum.values()){
if(code.intValue() == item.code.intValue()){
return item.desc;
}
}
return "";
}
}
... ...
package com.yoho.ufo.order.controller;
import com.yoho.order.model.TradeBillsReq;
import com.yoho.ufo.order.service.ITradeBillsService;
import com.yoho.ufo.service.model.ApiResponse;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yohobuy.ufo.model.order.resp.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "/tradeBills")
public class TradeBillsController {
private static final Logger LOGGER = LoggerFactory.getLogger(TradeBillsController.class);
@Autowired
private ITradeBillsService billsTradeService;
@RequestMapping(value = "/queryTradeBillsList")
public ApiResponse queryTradeBillsList(TradeBillsReq req) {
LOGGER.info("queryBillsTradeList in. req is {}", req);
PageResponseBO<TradeBillsResp> result = billsTradeService.queryTradeBillsList(req);
return new ApiResponse.ApiResponseBuilder().code(200).message("查询成功").data(result).build();
}
}
... ...
package com.yoho.ufo.order.service;
import com.yoho.order.model.TradeBillsReq;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yohobuy.ufo.model.order.resp.TradeBillsResp;
public interface ITradeBillsService {
PageResponseBO<TradeBillsResp> queryTradeBillsList(TradeBillsReq req);
}
... ...
package com.yoho.ufo.order.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.order.dal.TradeBillsMapper;
import com.yoho.order.model.*;
import com.yoho.ufo.order.constant.TradeStatusEnum;
import com.yoho.ufo.order.service.ITradeBillsService;
import com.yoho.ufo.service.impl.UserHelper;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yohobuy.ufo.model.order.resp.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author craig.qin
*/
@Service
public class TradeBillsServiceImpl implements ITradeBillsService {
private static final Logger LOGGER = LoggerFactory.getLogger(TradeBillsServiceImpl.class);
@Autowired
private ServiceCaller serviceCaller;
@Value("${ip.port.uic.server}")
private String uicServerIpAndPort;
private static final String UIC_GETPROFILE_URL = "/uic/profile/getProfile";
private static final String UIC_GETUSERPROFILE_URL = "/uic/profile/getUserProfile";
@Autowired
private TradeBillsMapper tradeBillsMapper;
public PageResponseBO<TradeBillsResp> queryTradeBillsList(TradeBillsReq req) {
if(!checkAndBuildParam(req)) {
return null;
}
if(req.getUid()==null&&StringUtils.isNotBlank(req.getMobile())){
Integer uid = getUidByMobile(req.getMobile());
if(uid!=null){
req.setUid(uid);
}
}
int total = tradeBillsMapper.selectCountByCondition(req);
if(total == 0) {
return null;
}
List<TradeBills> tradeBillsList = tradeBillsMapper.selectByConditionWithPage(req);
if(CollectionUtils.isEmpty(tradeBillsList)) {
return null;
}
List<TradeBillsResp> respList = convertToResp(tradeBillsList);
PageResponseBO<TradeBillsResp> result=new PageResponseBO<>();
result.setList(respList);
result.setPage(req.getPage());
result.setSize(req.getSize());
result.setTotal(total);
return result;
}
private boolean checkAndBuildParam(TradeBillsReq req){
/*if(req.getUid()==null&&req.getOrderCode()==null&&StringUtils.isBlank(req.getMobile())){
return false;
}*/
return true;
}
private List<TradeBillsResp> convertToResp(List<TradeBills> tradeBillsList){
List<TradeBillsResp> respList = Lists.newArrayList();
for(TradeBills item : tradeBillsList) {
TradeBillsResp resp=new TradeBillsResp();
resp.setId(item.getId());
resp.setUid(item.getUid());
resp.setMobile(getMobileByUid(item.getUid()));
resp.setOrderCode(item.getOrderCode());
resp.setAmount(item.getAmount());
resp.setIncomeOutcome(item.getIncomeOutcome());
resp.setCreateTimeStr(null == item.getCreateTime() ? "" : DateUtil.long2DateStr(item.getCreateTime().longValue()*1000, "yyyy-MM-dd HH:mm:ss"));
resp.setOperatorUid(item.getDealUid());
resp.setOperatorName(item.getDealUid()==0?"系统":item.getDealUserName());
resp.setTradeStatus(item.getTradeStatus());
//打款失败原因
if(100!=item.getTradeStatus()){
String failReason = TradeStatusEnum.getDescByCode(item.getTradeStatus());
resp.setTradeStatusDesc(StringUtils.isBlank(failReason)?String.valueOf(item.getTradeStatus()):failReason);
}
respList.add(resp);
}
return respList;
}
private String getMobileByUid(Integer uid) {
LOGGER.info("TradeBillsServiceImpl call getMobileByUid uid is{}", uid);
Map<String,Integer> request = Collections.singletonMap("uid", uid);
JSONObject jsonObject = serviceCaller.get("uic.getProfileAction", "http://" + uicServerIpAndPort + UIC_GETPROFILE_URL, request, JSONObject.class, null).get(1);
if(null == jsonObject.getJSONObject("data") || null == jsonObject.getJSONObject("data").getString("mobile_phone")) {
return null;
}
return jsonObject.getJSONObject("data").getString("mobile_phone");
}
private Integer getUidByMobile(String mobile) {
Map<String,String> request = Collections.singletonMap("account", mobile);
JSONObject jsonObject = serviceCaller.get("uic.getProfileAction", "http://" + uicServerIpAndPort + UIC_GETPROFILE_URL, request, JSONObject.class, null).get(1);
if(null == jsonObject.getJSONObject("data") || null == jsonObject.getJSONObject("data").getInteger("uid")) {
return null;
}
return jsonObject.getJSONObject("data").getInteger("uid");
}
}
... ...
... ... @@ -31,6 +31,7 @@ datasources:
- com.yoho.order.dal.ExpressRecordMapper
- com.yoho.order.dal.AreaMapper
- com.yoho.order.dal.OrderOperateRecordMapper
- com.yoho.order.dal.TradeBillsMapper
readOnlyInSlave: true
... ...
... ... @@ -31,5 +31,6 @@ datasources:
- com.yoho.order.dal.ExpressRecordMapper
- com.yoho.order.dal.AreaMapper
- com.yoho.order.dal.OrderOperateRecordMapper
- com.yoho.order.dal.TradeBillsMapper
readOnlyInSlave: ${readOnlyInSlave}
... ...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>Yoho!Buy运营平台</title>
<script src="/ufoPlatform/js/include.js"></script>
</head>
<body class="easyui-layout">
<input type="hidden" id="buyerOrderCode">
<input type="skup" id="skup">
<div region="north" style="height:180px;">
<script>
document.write(addHead('打款管理', '列表管理'));
</script>
<div style="padding:20px;">
<label>订单编号:</label>
<input id="orderCode" type="text" class="easyui-textbox" style="width:150px">
<label>UID:</label>
<input id="uid" type="text" class="easyui-textbox" style="width:150px"/>
<label>手机号:</label>
<input id="mobile" type="text" class="easyui-textbox" style="width:150px"/>
<label>订单状态:</label>
<select id="status" class="easyui-combobox" style="width:100px;" >
<option value="">全部状态</option>
<option value="100">打款成功</option>
<option value="999">打款失败</option>
</select>
<a id="searchBtn" class="btn-info">查询</a>
<!--<a id="allBtn" class="btn-success">全部</a>-->
</div>
</div>
<div id="tradeBillsList" region="center">
<table id="tradeBillsListTable"></table>
</div>
<script>
$(function() {
$("#status").combobox({
panelHeight:'auto',
multiple:false,
});
$("#searchBtn").linkbutton({
iconCls : "icon-search",
onClick : function() {
/*if(!$("#orderCode").val()
&& !$("#uid").val()
&& !$("#mobile").val()){
$.messager.alert("提示","请录入查询条件<br/>[订单编号、UID、手机号]至少选择一个!");
$("#orderCode").focus();
return;
}*/
$("#tradeBillsListTable").datagrid("load", {
status : $("#status").myCombobox("getValue"),
orderCode : $("#orderCode").val(),
uid : $("#uid").val(),
mobile : $("#mobile").val()
});
}
});
//全部按钮
/* $("#allBtn").linkbutton({
iconCls: "icon-import",
onClick: function () {
$("#orderCode").textbox('setValue','');
$("#status").combobox('setValue','');
//$("#uid").textbox('setValue','');
$("#mobile").textbox('setValue','');
$("#orderListTable").datagrid("load", {
});
}
});*/
getTradeBillsList();
});
function getTradeBillsList(){
$("#tradeBillsListTable").myDatagrid({
fit: true,
fitColumns: true,
striped: true,
url: contextPath + "/tradeBills/queryTradeBillsList",
method: 'POST',
queryParams: {},
loadFilter: function (data) {
var temp = defaultLoadFilter(data);
temp=null==temp?[]:temp;
temp.rows = temp.list;
return temp;
},
columns: [[{
title: "订单编号",
field: "orderCode",
width: 30,
align: "center"
},{
title: "打款金额",
field: "amount",
width: 30,
align: "center"
},{
title: "用户uid",
field: "uid",
width: 30,
align: "center"
},{
title: "用户手机号",
field: "mobile",
width: 30,
align: "center"
} ,{
title: "打款时间",
field: "createTimeStr",
width: 20,
align: "center"
},{
title: "操作员",
field: "operatorName",
width: 20,
align: "center"
},{
title: "订单状态",
field: "tradeStatus",
width: 20,
align: "center",
formatter: function (value, rowData, rowIndex) {
if (value == 100) {
return "打款成功";
}else {
return "<span style='color: red'>打款失败</span>";
}
}
}, {
title: "原因",
field: "tradeStatusDesc",
width: 20,
align: "center"
}, {
title: "操作",
field: "asdf",
width: 40,
align: "center",
formatter: function (value, rowData, rowIndex) {
if (rowData.tradeStatus != 100) {
return "<a role='refundsConfirm' dataId='"+ rowData.id +"' style='margin-left:10px;background-color: #5cb85c !important;'>打款</a>";
}
}
}]],
cache: false,
pagination: true,
//pageSize: 20,
idField: "id",
singleSelect: true,
onLoadSuccess: function (data) {
$(this).datagrid("getPanel").find("a[role='refundsConfirm']").linkbutton({
onClick: function () {
var id = $(this).attr("dataId");
alert("开发中。。");
}
});
}
});
}
</script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -65,7 +65,7 @@
width: 171,
height: 120,
realInputName: "brandLogo",
url: contextPath + '/fileupload/uploadFile',
url: contextPath + '/fileupload/upload',
queryParams: {
bucket: "goodsimg"
},
... ... @@ -83,7 +83,7 @@
$.messager.alert("错误", data.message);
return "";
}
return data.data.url;
return data.data;
},
onLoadSuccess: function (data) {
$.messager.progress("close");
... ...
... ... @@ -52,7 +52,7 @@
width: 171,
height: 120,
realInputName: "colorValue",
url: contextPath + '/fileupload/uploadFile',
url: contextPath + '/fileupload/upload',
queryParams: {
bucket: "goodsimg"
},
... ... @@ -70,7 +70,7 @@
$.messager.alert("错误", data.message);
return "";
}
return data.data.url;
return data.data;
},
onLoadSuccess: function (data) {
$.messager.progress("close");
... ...
... ... @@ -405,7 +405,7 @@
width: 104,
height: 104,
realInputName: "goodsImage",
url: contextPath + '/fileupload/uploadFile',
url: contextPath + '/fileupload/upload',
queryParams: {
bucket: "goodsimg"
},
... ... @@ -428,7 +428,7 @@
onLoadSuccess: function (data) {
$.messager.progress("close");
$(document).find('.file-close').click();
that.dom.imageUpload.before('<div class="img" data-url="' + data.data.url + '" style="background-image:url(' + data.data.url + ');">');
that.dom.imageUpload.before('<div class="img" data-url="' + data.data + '" style="background-image:url(' + data.data + ');">');
return false;
}
});
... ...