作者 唐旭辉

更新

package controllers
import (
"encoding/json"
"errors"
"fmt"
"time"
"github.com/GeeTeam/gt3-golang-sdk/geetest"
"github.com/astaxie/beego/logs"
userCmd "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/users/command"
userService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/users/service"
... ... @@ -54,27 +51,26 @@ func (c *AdminLoginController) Login() {
}
//CaptchaInit 极验初始化
func (c *AdminLoginController) CaptchaInit() {
const (
captchaID = "33a2abf9c5df0d6bc3b89fb39280114b"
privateKey = "13320fd2b10199e9a2440a4fbb4d46f7"
)
newGeetest := geetest.NewGeetestLib(captchaID, privateKey, 2*time.Second)
userip := c.Ctx.Input.IP()
_, responseBt := newGeetest.PreProcess("", userip)
// c.SetSession("geetest_status", status)
var geetestRsp geetest.FailbackRegisterRespnse
json.Unmarshal(responseBt, &geetestRsp)
//对前端定义的数据格式进行适配。。。
rspData := map[string]interface{}{
"success": geetestRsp.Success,
"gt": geetestRsp.GT,
"challenge": geetestRsp.Challenge,
"newCaptcha": geetestRsp.NewCaptcha,
}
c.ResponseData(rspData)
return
}
// func (c *AdminLoginController) CaptchaInit() {
// const (
// captchaID = "33a2abf9c5df0d6bc3b89fb39280114b"
// privateKey = "13320fd2b10199e9a2440a4fbb4d46f7"
// )
// newGeetest := geetest.NewGeetestLib(captchaID, privateKey, 2*time.Second)
// userip := c.Ctx.Input.IP()
// _, responseBt := newGeetest.PreProcess("", userip)
// var geetestRsp geetest.FailbackRegisterRespnse
// json.Unmarshal(responseBt, &geetestRsp)
// //对前端定义的数据格式进行适配。。。
// rspData := map[string]interface{}{
// "success": geetestRsp.Success,
// "gt": geetestRsp.GT,
// "challenge": geetestRsp.Challenge,
// "newCaptcha": geetestRsp.NewCaptcha,
// }
// c.ResponseData(rspData)
// return
// }
//AdminpPofile 获取登录用户的权限配置
func (c *AdminLoginController) AdminpPofile() {
... ...
... ... @@ -106,120 +106,6 @@ func (c *OrderDividendController) PageListOrderDividend() {
return
}
//OrderDividendDetail 订单的分红详情
// func (c *OrderDividendController) OrderDividendDetail() {
// type Parameter struct {
// Id string `json:"id"`
// }
// var (
// param Parameter
// err error
// )
// if err = c.BindJsonData(&param); err != nil {
// logs.Error(err)
// c.ResponseError(errors.New("json数据解析失败"))
// return
// }
// orderid, _ := strconv.ParseInt(param.Id, 10, 64)
// if orderid == 0 {
// c.ResponseError(errors.New("参数错误"))
// return
// }
// companyId := c.GetUserCompany()
// orderSrv := orderService.NewOrderInfoService(nil)
// orderinfo, err := orderSrv.GetOrderDetail(orderQuery.GetOrderQuery{
// OrderId: orderid,
// CompanyId: companyId,
// })
// if err != nil {
// c.ResponseError(err)
// return
// }
// if orderinfo.OrderType != domain.OrderReal {
// c.ResponseError(errors.New("参数错误"))
// return
// }
// allGoods := []map[string]interface{}{}
// for _, v := range orderinfo.Goods {
// detail := map[string]interface{}{
// "productName": v.GoodName,
// "orderNum": v.PlanGoodNumber,
// "univalence": v.Price,
// "partnerRatio": v.PartnerBonusPercent,
// "orderPrice": v.GoodCompute.PlanAmount,
// "partnerDividendsReceivable": v.GoodCompute.PlanPartnerBonus,
// }
// m := map[string]interface{}{
// "detail": detail,
// "quantityControl": "",
// "id": v.Id,
// "stateOfPayment": v.BonusStatus,
// "remark": v.Remark,
// "amountControl": "",
// "partnerDividendControl": "",
// "receivedDividends": v.GoodCompute.PartnerBonusHas,
// "notReceivedDividend": v.GoodCompute.PartnerBonusNot,
// "dividendSpending": v.GoodCompute.PartnerBonusExpense,
// }
// if v.GoodCompute.UseAmount >= 0 {
// m["amountControl"] = fmt.Sprint(v.GoodCompute.UseAmount)
// }
// if v.UseGoodNumber >= 0 {
// m["quantityControl"] = fmt.Sprint(v.UseGoodNumber)
// }
// if v.GoodCompute.UsePartnerBonus >= 0 {
// m["partnerDividendControl"] = fmt.Sprint(v.GoodCompute.UsePartnerBonus)
// }
// allGoods = append(allGoods, m)
// }
// orderData := map[string]interface{}{
// "buyer": orderinfo.Buyer.BuyerName,
// "shipmentsId": orderinfo.DeliveryCode,
// "orderDist": orderinfo.RegionInfo.RegionName,
// "partner": orderinfo.PartnerInfo.PartnerName,
// "id": orderinfo.Id,
// "orderId": orderinfo.OrderCode,
// "partnerCategoryId": orderinfo.PartnerCategory.Id,
// "partnerCategoryName": orderinfo.PartnerCategory.Name,
// }
// dividendCount := map[string]interface{}{
// "orderNum": orderinfo.OrderCompute.PlanOrderCount,
// "orderAmountAdjustment": orderinfo.OrderCompute.PlanOrderAmount,
// "orderNumControl": "",
// "orderAmountAdjustmentControl": "",
// "partnerDividends": orderinfo.OrderCompute.PlanPartnerBonus,
// "partnerDividendsControl": "",
// "receivedDividends": orderinfo.OrderCompute.PartnerBonusHas,
// "notReceivedDividend": orderinfo.OrderCompute.PartnerBonusNot,
// "dividendSpending": orderinfo.OrderCompute.PartnerBonusExpense,
// "commissionProportion": orderinfo.SalesmanBonusPercent,
// "expectedCommission": orderinfo.OrderCompute.SalesmanBonus,
// }
// if orderinfo.OrderCompute.UseOrderAmount >= 0 {
// dividendCount["orderAmountAdjustmentControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderAmount)
// }
// if orderinfo.OrderCompute.UsePartnerBonus >= 0 {
// dividendCount["partnerDividendsControl"] = fmt.Sprint(orderinfo.OrderCompute.UsePartnerBonus)
// }
// if orderinfo.OrderCompute.UseOrderCount >= 0 {
// dividendCount["orderNumControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderCount)
// }
// rsp := map[string]interface{}{
// "order": orderData,
// "product": allGoods,
// "dividendCount": dividendCount,
// "operationTime": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:06"),
// }
// if orderinfo.OrderCompute.UseOrderAmount >= 0 {
// rsp["orderNumCountControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderAmount)
// }
// if orderinfo.OrderCompute.UseOrderCount >= 0 {
// rsp["orderAmountAdjustmentCountControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderCount)
// }
// c.ResponseData(rsp)
// return
// }
func (c *OrderDividendController) OrderDividendDetail() {
type Parameter struct {
Id string `json:"id"`
... ... @@ -261,64 +147,6 @@ type postDividendPayment struct {
Remark string `json:"remark"`
}
// func (c *OrderDividendController) EditOrderDividend() {
// var (
// param postOrderDividend
// err error
// )
// if err = c.BindJsonData(&param); err != nil {
// logs.Error(err)
// c.ResponseError(errors.New("json数据解析失败"))
// return
// }
// if param.Id == 0 {
// c.ResponseError(errors.New("参数错误"))
// return
// }
// goodbouns := []orderCmd.GoodBouns{}
// for _, v := range param.DividendPayments {
// if v.ProductId == 0 {
// c.ResponseError(errors.New("参数错误"))
// return
// }
// if !(v.StateOfPayment == domain.OrderGoodWaitPay || v.StateOfPayment == domain.OrderGoodHasPay) {
// c.ResponseError(errors.New("参数错误"))
// return
// }
// g := orderCmd.GoodBouns{
// GoodId: v.ProductId,
// Remark: v.Remark,
// BounsStatus: v.StateOfPayment,
// }
// if len(v.QuantityControl) == 0 {
// g.UseGoodNumber = -1
// } else {
// num, err := strconv.Atoi(v.QuantityControl)
// if err != nil {
// c.ResponseError(errors.New("参数错误"))
// return
// }
// g.UseGoodNumber = num
// }
// goodbouns = append(goodbouns, g)
// }
// companyId := c.GetUserCompany()
// cmd := orderCmd.UpdateGoodBouns{
// Id: param.Id,
// GoodBouns: goodbouns,
// CompanyId: companyId,
// }
// orderSrv := orderService.NewOrderInfoService(nil)
// err = orderSrv.UpdateGoodBouns(cmd)
// if err != nil {
// c.ResponseError(err)
// return
// }
// c.ResponseData(nil)
// return
// }
//OrderDividendDetailForBestshop 海鲜干货的订单分红详情
func (c *OrderDividendController) OrderDividendDetailForBestshop() {
type Parameter struct {
... ... @@ -529,15 +357,6 @@ func (c *OrderDividendController) BatchPayOrderGoodBonus() {
c.ResponseError(errors.New("json数据解析失败"))
return
}
// var orderids []int64
// for _, v := range param.OrderIds {
// orderid, _ := strconv.ParseInt(v, 10, 64)
// if orderid == 0 {
// c.ResponseError(errors.New("参数错误"))
// return
// }
// orderids = append(orderids, orderid)
// }
adminId := c.GetUserId()
orderSrv := orderService.NewOrderInfoService(nil)
err = orderSrv.BatchPayPartnerBonus(param.OrderIds, adminId)
... ...
... ... @@ -33,142 +33,6 @@ func (c *OrderInfoController) Prepare() {
}
}
//PageListOrderPurpose 分页获取意向订单列表
// func (c *OrderInfoController) PageListOrderPurpose() {
// type Parameter struct {
// SearchText string `json:"searchText"`
// Partner int64 `json:"partner"`
// PageSize int `json:"pageSize"`
// PageNumber int `json:"pageNumber"`
// }
// var (
// param Parameter
// err error
// )
// if err = c.BindJsonData(&param); err != nil {
// logs.Error(err)
// c.ResponseError(errors.New("json数据解析失败"))
// return
// }
// if param.PageNumber == 0 {
// param.PageNumber = 1
// }
// if param.PageSize == 0 {
// param.PageSize = 20
// }
// companyId := c.GetUserCompany()
// orderSrv := orderService.NewOrderInfoService(nil)
// orderinfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{
// PartnerId: param.Partner,
// OrderCode: param.SearchText,
// OrderType: domain.OrderIntention,
// Limit: param.PageSize,
// Offset: (param.PageNumber - 1) * param.PageSize,
// CompanyId: companyId,
// })
// if err != nil {
// c.ResponseError(err)
// return
// }
// rsp := []map[string]interface{}{}
// for i := range orderinfos {
// orderinfo := orderinfos[i]
// m := map[string]interface{}{
// "createTime": orderinfo.CreateTime.Local().Format("2006-01-02 15:04:05"),
// "updateTime": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:05"),
// "buyer": orderinfo.Buyer.BuyerName,
// "id": orderinfo.Id,
// "orderId": orderinfo.OrderCode,
// "partner": orderinfo.PartnerInfo.PartnerName,
// "orderNum": orderinfo.OrderCompute.PlanOrderCount,
// "orderPrice": orderinfo.OrderCompute.PlanOrderAmount,
// "orderDist": orderinfo.RegionInfo.RegionName,
// }
// rsp = append(rsp, m)
// }
// c.ResponsePageList(rsp, cnt, param.PageNumber)
// }
//GetOrderPurpose 获取意向订单详情
// func (c *OrderInfoController) GetOrderPurpose() {
// type Parameter struct {
// Id string `json:"id"`
// }
// var (
// param Parameter
// err error
// )
// if err = c.BindJsonData(&param); err != nil {
// logs.Error(err)
// c.ResponseError(errors.New("json数据解析失败"))
// return
// }
// orderid, _ := strconv.ParseInt(param.Id, 10, 64)
// companyId := c.GetUserCompany()
// orderSrv := orderService.NewOrderInfoService(nil)
// orderinfo, err := orderSrv.GetOrderDetail(orderQuery.GetOrderQuery{
// OrderId: orderid,
// CompanyId: companyId,
// })
// if err != nil {
// c.ResponseError(err)
// return
// }
// if orderinfo.OrderType != domain.OrderIntention {
// c.ResponseError(errors.New("参数错误"))
// return
// }
// allGoods := []map[string]interface{}{}
// for _, v := range orderinfo.Goods {
// m := map[string]interface{}{
// "id": v.Id,
// "productName": v.GoodName,
// "orderNum": v.PlanGoodNumber,
// "univalence": v.Price,
// "partnerRatio": v.PartnerBonusPercent,
// "orderPrice": v.GoodCompute.PlanAmount,
// }
// allGoods = append(allGoods, m)
// }
// rsp := map[string]interface{}{
// "buyer": orderinfo.Buyer.BuyerName,
// "id": orderinfo.Id,
// "partnerID": orderinfo.PartnerInfo.Id,
// "partner": orderinfo.PartnerInfo.PartnerName,
// "orderDist": orderinfo.RegionInfo.RegionName,
// "orderId": orderinfo.OrderCode,
// "product": allGoods,
// "commissionProportion": orderinfo.SalesmanBonusPercent,
// "orderNumCount": orderinfo.OrderCompute.PlanOrderCount,
// "orderAmountAdjustmentCount": orderinfo.OrderCompute.PlanOrderAmount,
// }
// c.ResponseData(rsp)
// }
//RemoveOrderPurpose 删除意向订单
// func (c *OrderInfoController) RemoveOrderPurpose() {
// type Parameter struct {
// Id int64 `json:"id"`
// }
// var (
// param Parameter
// err error
// )
// if err = c.BindJsonData(&param); err != nil {
// logs.Error(err)
// c.ResponseError(errors.New("json数据解析失败"))
// return
// }
// companyId := c.GetUserCompany()
// orderSrv := orderService.NewOrderInfoService(nil)
// err = orderSrv.DeleteOrder(param.Id, companyId)
// if err != nil {
// c.ResponseError(err)
// return
// }
// c.ResponseData(nil)
// }
//postPurposeOrderDetail 请求添加/更新的订单数据
type postPurposeOrderDetail struct {
Id int64 `json:"id"`
... ... @@ -253,93 +117,6 @@ func (postData *postOrderGood) Valid() error {
return nil
}
// //UpdateOrderPurpose 更新意向订单
// func (c *OrderInfoController) UpdateOrderPurpose() {
// //用与适配前端定义的数据结构
// var (
// param postPurposeOrderDetail
// err error
// )
// if err = c.BindJsonData(&param); err != nil {
// logs.Error(err)
// c.ResponseError(errors.New("json数据解析失败"))
// return
// }
// if err := param.Valid(); err != nil {
// c.ResponseError(err)
// return
// }
// if param.Id == 0 {
// err = c.addOrderPurpose(param)
// } else {
// err = c.editOrderPurpose(param)
// }
// if err != nil {
// c.ResponseError(err)
// }
// c.ResponseData(nil)
// return
// }
// func (c *OrderInfoController) addOrderPurpose(param postPurposeOrderDetail) error {
// newGoods := []orderCmd.OrderGoodData{}
// for _, v := range param.Product {
// g := orderCmd.OrderGoodData{
// GoodName: v.ProductName,
// PlanGoodNumber: v.OrderNum,
// Price: v.Univalence,
// PartnerBonusPercent: v.PartnerRatio,
// }
// newGoods = append(newGoods, g)
// }
// companyId := c.GetUserCompany()
// createcmd := orderCmd.CreateOrderCommand{
// OrderType: domain.OrderIntention,
// OrderCode: param.OrderId,
// DeliveryCode: "",
// BuyerName: param.BuyerName,
// OrderRegion: param.OrderDist,
// PartnerId: param.PartnerId,
// SalesmanBonusPercent: param.CommissionProportion,
// Goods: newGoods,
// CompanyId: companyId,
// }
// orderSrv := orderService.NewOrderInfoService(nil)
// _, err := orderSrv.CreateNewOrder(createcmd)
// return err
// }
// func (c *OrderInfoController) editOrderPurpose(param postPurposeOrderDetail) error {
// orderSrv := orderService.NewOrderInfoService(nil)
// newGoods := []orderCmd.OrderGoodData{}
// for _, v := range param.Product {
// g := orderCmd.OrderGoodData{
// GoodName: v.ProductName,
// PlanGoodNumber: v.OrderNum,
// Price: v.Univalence,
// PartnerBonusPercent: v.PartnerRatio,
// }
// newGoods = append(newGoods, g)
// }
// companyId := c.GetUserCompany()
// updatecmd := orderCmd.UpdateOrderCommand{
// Id: param.Id,
// OrderType: domain.OrderIntention,
// OrderCode: param.OrderId,
// DeliveryCode: "",
// BuyerName: param.BuyerName,
// OrderRegion: param.OrderDist,
// PartnerId: param.PartnerId,
// SalesmanBonusPercent: param.CommissionProportion,
// Goods: newGoods,
// CompanyId: companyId,
// }
// _, err := orderSrv.UpdateOrderData(updatecmd)
// return err
// }
type postOrderPurposeDelivery struct {
ShipmentsId string `json:"shipmentsId"` //发货单号
Id string `json:"id"` //订单id
... ... @@ -364,51 +141,6 @@ func (postData *postOrderPurposeDelivery) Valid() error {
return nil
}
//OrderPurposeDelivery 发货 意向订单转实发单
// func (c *OrderInfoController) OrderPurposeDelivery() {
// //用与适配前端定义的数据结构
// var (
// param postOrderPurposeDelivery
// err error
// )
// if err = c.BindJsonData(&param); err != nil {
// logs.Error(err)
// c.ResponseError(errors.New("json数据解析失败"))
// return
// }
// param.ShipmentsId = strings.TrimSpace(param.ShipmentsId)
// orderid, _ := strconv.ParseInt(param.Id, 10, 64)
// if orderid <= 0 {
// c.ResponseError(errors.New("参数错误"))
// return
// }
// if err = param.Valid(); err != nil {
// c.ResponseError(err)
// return
// }
// goods := []orderCmd.OrderGoodData{}
// for _, v := range param.ProductDetail {
// g := orderCmd.OrderGoodData{
// Id: v.Id, GoodName: v.ProductName, PlanGoodNumber: v.OrderNum,
// Price: v.Univalence, PartnerBonusPercent: v.PartnerRatio,
// }
// goods = append(goods, g)
// }
// companyId := c.GetUserCompany()
// deliveryCommand := orderCmd.OrderDeliveryCommand{
// OrderId: orderid, DeliveryCode: param.ShipmentsId,
// DeliveryTime: time.Now(), Goods: goods, CompanyId: companyId,
// }
// orderSrv := orderService.NewOrderInfoService(nil)
// err = orderSrv.Delivery(deliveryCommand)
// if err != nil {
// c.ResponseError(err)
// }
// c.ResponseData(nil)
// return
// }
//PageListOrderReal 获取实发订单列表
func (c *OrderInfoController) PageListOrderReal() {
type Parameter struct {
... ...
... ... @@ -22,29 +22,18 @@ func init() {
beego.NSRouter("/add", &controllers.PartnerInfoController{}, "POST:CreatePartnerInfo"),
beego.NSRouter("/edit", &controllers.PartnerInfoController{}, "POST:UpdatePartnerInfo"),
beego.NSRouter("/detail", &controllers.PartnerInfoController{}, "POST:GetPartnerInfo"),
//beego.NSRouter("/set-status", &controllers.PartnerInfoController{}, "POST:PartnerInfoSetState"),
beego.NSRouter("/batchDisabled", &controllers.PartnerInfoController{}, "POST:PartnerInfoSetState"),
),
beego.NSNamespace("/dividends",
beego.NSRouter("/list", &controllers.OrderDividendController{}, "POST:PageListOrderDividend"),
beego.NSRouter("/modify", &controllers.OrderDividendController{}, "POST:EditOrderDividend"),
beego.NSRouter("/detail", &controllers.OrderDividendController{}, "POST:OrderDividendDetail"),
// beego.NSRouter("/mini-program/detail", &controllers.OrderDividendController{}, "POST:OrderDividendDetailForBestshop"),
//beego.NSRouter("/mini-program/modify", &controllers.OrderDividendController{}, "POST:EditOrderDividendForBestshop"),
beego.NSRouter("/payDividends", &controllers.OrderDividendController{}, "POST:PayOrderGoodBonus"),
beego.NSRouter("/payDividends/batch", &controllers.OrderDividendController{}, "POST:BatchPayOrderGoodBonus"),
beego.NSRouter("/remarks", &controllers.OrderDividendController{}, "POST:EditOrderRemarkBonus"),
beego.NSRouter("/list/excel", &controllers.OrderDividendController{}, "POST:ListOrderBonusForExcel"),
// beego.NSRouter("/business/detail", &controllers.BusinessBonusController{}, "POST:GetBusinessBonus"),
// beego.NSRouter("/business/edit", &controllers.BusinessBonusController{}, "POST:UpdateBusinessBonus"),
// beego.NSRouter("/business/list", &controllers.BusinessBonusController{}, "POST:ListBusinessBonus"),
),
beego.NSNamespace("/order",
// beego.NSRouter("/purpose/list", &controllers.OrderInfoController{}, "POST:PageListOrderPurpose"),
// beego.NSRouter("/purpose/update", &controllers.OrderInfoController{}, "POST:UpdateOrderPurpose"),
// beego.NSRouter("/purpose/detail", &controllers.OrderInfoController{}, "POST:GetOrderPurpose"),
// beego.NSRouter("/purpose/del", &controllers.OrderInfoController{}, "POST:RemoveOrderPurpose"),
// beego.NSRouter("/purpose/sendout", &controllers.OrderInfoController{}, "POST:OrderPurposeDelivery"),
beego.NSRouter("/actual/list", &controllers.OrderInfoController{}, "POST:PageListOrderReal"),
beego.NSRouter("/actual/list/excel", &controllers.OrderInfoController{}, "POST:ListOrderForExcel"),
beego.NSRouter("/actual/detail", &controllers.OrderInfoController{}, "POST:GetOrderReal"),
... ...