Commit 1d4c88d5 authored by gaodapeng's avatar gaodapeng

no message

parent 4e7d35ad
......@@ -85,4 +85,5 @@ dependencies {
implementation 'com.github.d-max:spots-dialog:1.1@aar'
implementation 'com.elvishew:xlog:1.10.1'
implementation 'com.squareup.leakcanary:leakcanary-android:2.7'
implementation 'com.contrarywind:Android-PickerView:4.1.9'
}
\ No newline at end of file
package com.miya.fastcashier.beans;
import android.text.TextUtils;
import com.sdy.miya.moblie.component.pay.platform.bean.BaseDO;
import com.sdy.miya.moblie.component.pay.platform.bean.QueryTradesByTimeResponse;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
public class ViewOrderStatisticsInfo extends BaseDO {
private String beginDate;
private String endDate;
private StatisticBean totalStatistic;
private List<StatisticBean> typeStatistic;
public String getBeginDate() {
return beginDate;
}
public void setBeginDate(String beginDate) {
this.beginDate = beginDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
public StatisticBean getTotalStatistic() {
return totalStatistic;
}
public void setTotalStatistic(StatisticBean totalStatistic) {
this.totalStatistic = totalStatistic;
}
public List<StatisticBean> getTypeStatistic() {
return typeStatistic;
}
public void setTypeStatistic(List<StatisticBean> typeStatistic) {
this.typeStatistic = typeStatistic;
}
public static class StatisticBean extends BaseDO {
/**
* 支付方式
*/
private String payType;
/**
* 交易笔数
*/
private int tradeCount;
/**
* 交易总金额
*/
private int tradeTotalAmount;
/**
* 退款笔数
*/
private int refundCount;
/**
* 退款总金额
*/
private int refundTotalAmount;
/**
* 商户优惠
*/
private int merchantDiscount;
/**
* 平台优惠
*/
private int platformDiscount;
/**
* 退款商户优惠
*/
private int refundMerchantDiscount;
/**
* 退款平台优惠
*/
private int refundPlatformDiscount;
public String getPayType() {
return payType;
}
public void setPayType(String payType) {
this.payType = payType;
}
public int getTradeCount() {
return tradeCount;
}
public void setTradeCount(int tradeCount) {
this.tradeCount = tradeCount;
}
public int getTradeTotalAmount() {
return tradeTotalAmount;
}
public void setTradeTotalAmount(int tradeTotalAmount) {
this.tradeTotalAmount = tradeTotalAmount;
}
public int getRefundCount() {
return refundCount;
}
public void setRefundCount(int refundCount) {
this.refundCount = refundCount;
}
public int getRefundTotalAmount() {
return refundTotalAmount;
}
public void setRefundTotalAmount(int refundTotalAmount) {
this.refundTotalAmount = refundTotalAmount;
}
public int getMerchantDiscount() {
return merchantDiscount;
}
public void setMerchantDiscount(int merchantDiscount) {
this.merchantDiscount = merchantDiscount;
}
public int getPlatformDiscount() {
return platformDiscount;
}
public void setPlatformDiscount(int platformDiscount) {
this.platformDiscount = platformDiscount;
}
public int getRefundMerchantDiscount() {
return refundMerchantDiscount;
}
public void setRefundMerchantDiscount(int refundMerchantDiscount) {
this.refundMerchantDiscount = refundMerchantDiscount;
}
public int getRefundPlatformDiscount() {
return refundPlatformDiscount;
}
public void setRefundPlatformDiscount(int refundPlatformDiscount) {
this.refundPlatformDiscount = refundPlatformDiscount;
}
}
public static ViewOrderStatisticsInfo transfer(QueryTradesByTimeResponse queryTradesByTimeResponse, String beginDate, String endDate) {
ViewOrderStatisticsInfo statisticsInfo = new ViewOrderStatisticsInfo();
statisticsInfo.setBeginDate(beginDate);
statisticsInfo.setEndDate(endDate);
if (!TextUtils.isEmpty(queryTradesByTimeResponse.getBillInformation())) {
String billInformation = queryTradesByTimeResponse.getBillInformation();
String[] serial = billInformation.split(";");
if (serial.length > 0) {
statisticsInfo.typeStatistic = new ArrayList<>();
for (int i = 0; i < serial.length; i++) {
if (!TextUtils.isEmpty(serial[i])) {
String[] values = serial[i].split(",");
StatisticBean statisticBean = new StatisticBean();
for (int j = 0; j < values.length; j++) {
valueToField(statisticBean, values[j], j);
}
statisticsInfo.typeStatistic.add(statisticBean);
}
}
}
}
statisticsInfo.totalStatistic = new StatisticBean();
statisticsInfo.totalStatistic.payType = null;
statisticsInfo.totalStatistic.tradeCount = queryTradesByTimeResponse.getTradeCount();
statisticsInfo.totalStatistic.tradeTotalAmount = queryTradesByTimeResponse.getTradeTotalAmount();
statisticsInfo.totalStatistic.refundCount = queryTradesByTimeResponse.getRefundCount();
statisticsInfo.totalStatistic.refundTotalAmount = queryTradesByTimeResponse.getRefundTotalAmount();
statisticsInfo.totalStatistic.merchantDiscount = queryTradesByTimeResponse.getMerchantDiscount();
statisticsInfo.totalStatistic.platformDiscount = queryTradesByTimeResponse.getPlatformDiscount();
statisticsInfo.totalStatistic.refundMerchantDiscount = queryTradesByTimeResponse.getRefundMerchantDiscount();
statisticsInfo.totalStatistic.refundPlatformDiscount = queryTradesByTimeResponse.getRefundPlatformDiscount();
return statisticsInfo;
}
private static void valueToField(StatisticBean statisticBean, String value, int index) {
switch (index) {
case 0:
statisticBean.payType = value;
break;
case 1:
statisticBean.tradeCount = toInt(value);
break;
case 2:
statisticBean.tradeTotalAmount = toInt(value);
break;
case 3:
statisticBean.refundCount = toInt(value);
break;
case 4:
statisticBean.refundTotalAmount = toInt(value);
break;
case 5:
statisticBean.merchantDiscount = toInt(value);
break;
case 6:
statisticBean.platformDiscount = toInt(value);
break;
case 7:
statisticBean.refundMerchantDiscount = toInt(value);
break;
case 8:
statisticBean.refundPlatformDiscount = toInt(value);
break;
}
}
private static int toInt(String value) {
if (TextUtils.isEmpty(value) && !TextUtils.isDigitsOnly(value)) {
return 0;
}
return new BigDecimal(value).intValue();
}
}
......@@ -4,14 +4,17 @@ import android.text.TextUtils
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.miya.fastcashier.dao.DatabaseKeeper
import com.miya.fastcashier.utils.isEmpty
import com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
import java.lang.RuntimeException
/**
* 封装层的
*/
@Entity(tableName = "pay_data")
data class ViewPayOrderData(
@PrimaryKey//以订单号为主键
@PrimaryKey(autoGenerate = true)
val id: Int = 0,//主键
val orderNo: String,//订单号
val tradStatus: String? = null,
val tradeNo: String? = null,//交易流水号
......@@ -19,7 +22,7 @@ data class ViewPayOrderData(
val chanelTag: String? = null,//支付方式
val buyerId: String? = null,//支付者id
val couponMessage: String? = null,
val chanelOrderTradeTime: String? = null,//支付时间
val chanelOrderTradeTime: String,//支付时间
val miyaResponseTime: String? = null,//返回支付时间
val miyaOrderDesc: String? = null,
val vipShopTag: String? = null,
......@@ -34,6 +37,9 @@ data class ViewPayOrderData(
companion object {
fun create(payServiceResponse: PayServiceResponse): ViewPayOrderData {
if (isEmpty(payServiceResponse.chanelOrderTradeTime)) {
throw RuntimeException("交易时间不可以为空")
}
return ViewPayOrderData(
orderNo = payServiceResponse.shopTradeNo,
tradStatus = payServiceResponse.tradStatus,
......
......@@ -2,23 +2,37 @@ package com.miya.fastcashier.dao
import androidx.room.*
import com.miya.fastcashier.beans.ViewPayOrderData
import com.miya.fastcashier.utils.MiYaPayPlantformPayWayEnum
@Dao
interface PayDataDao {
companion object{
const val NUM_OF_SINGLE_PAGE = 10
}
@Query("SELECT COUNT(*) FROM pay_data")
fun getSize(): Int
@Query("SELECT * FROM pay_data")
fun getAll(): MutableList<ViewPayOrderData>
@Query("SELECT * FROM pay_data LIMIT 20")
@Query("SELECT * FROM pay_data LIMIT $NUM_OF_SINGLE_PAGE")
fun getOnePage(): MutableList<ViewPayOrderData>
@Query("SELECT ceil(COUNT(*))/10")
fun getPageNum(): Int
@Query("SELECT * FROM pay_data WHERE chanelTag =:payType ORDER BY id DESC LIMIT $NUM_OF_SINGLE_PAGE offset :beginIndex ")
fun queryWithType(
payType: String,
beginIndex: Int
): MutableList<ViewPayOrderData>
@Query("SELECT COUNT(*) FROM pay_data WHERE chanelTag =:payType")
fun sizeOfType(payType: String): Int
@Insert
fun insertAll(list: MutableList<ViewPayOrderData>)
......
......@@ -10,6 +10,7 @@ import com.sdy.miya.moblie.component.pay.core.result.MiYaMobilePayResult
import com.sdy.miya.moblie.component.pay.core.result.ResultBuilder
import com.sdy.miya.moblie.component.pay.platform.MiYaPlatformPayService
import com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
import com.sdy.miya.moblie.component.pay.platform.bean.QueryTradesByTimeResponse
import java.lang.Exception
import java.text.SimpleDateFormat
import java.util.*
......@@ -23,7 +24,7 @@ object PayRepository {
* 支付功能
*/
@WorkerThread
fun pay(orderNo:String,payPrice:String,token:String,payType:String): PayServiceResponse {
fun pay(orderNo: String, payPrice: String, token: String, payType: String): PayServiceResponse {
val shopInfo = AccountService.getAccountInfo()?.shopInfo
......@@ -137,7 +138,7 @@ object PayRepository {
* 只支持微信或者支付宝
* payType 2是微信 1是支付宝
*/
fun generatePayCode(orderNo:String,payPrice:String,payType:String): PayServiceResponse {
fun generatePayCode(orderNo: String, payPrice: String, payType: String): PayServiceResponse {
val shopInfo = AccountService.getAccountInfo()?.shopInfo
......@@ -173,7 +174,7 @@ object PayRepository {
val calendar = Calendar.getInstance()
calendar.time = date;
//过期时间设置为超过2个小时即为过期
calendar.add(Calendar.HOUR_OF_DAY,2);
calendar.add(Calendar.HOUR_OF_DAY, 2);
date = calendar.time;
paramsMap["expireTime"] = DateUtils.format18(date)
......@@ -191,7 +192,7 @@ object PayRepository {
}
}
fun payResultQuery(orderNo:String): PayServiceResponse{
fun payResultQuery(orderNo: String): PayServiceResponse {
val shopInfo = AccountService.getAccountInfo()?.shopInfo
val baseUrl = shopInfo?.miyaPayPlatformUrl;
......@@ -224,11 +225,14 @@ object PayRepository {
MiYaPlatformPayService.getService().syncRequestOrderStateByOrderId(paramsMap)
if (miYaMobilePayResult != null && miYaMobilePayResult.resultCode == ResultBuilder.SUCCESS) {
return miYaMobilePayResult.payServiceResponse
} else if(!TextUtils.isEmpty(miYaMobilePayResult.errorMsg)){
} else if (!TextUtils.isEmpty(miYaMobilePayResult.errorMsg)) {
throw RuntimeException(miYaMobilePayResult.errorMsg)
}else if(miYaMobilePayResult.payServiceResponse != null && !TextUtils.isEmpty(miYaMobilePayResult.payServiceResponse.chanelErrorMsg)){
} else if (miYaMobilePayResult.payServiceResponse != null && !TextUtils.isEmpty(
miYaMobilePayResult.payServiceResponse.chanelErrorMsg
)
) {
throw RuntimeException(miYaMobilePayResult.payServiceResponse.chanelErrorMsg)
}else{
} else {
throw RuntimeException("支付异常!")
}
} catch (e: Exception) {
......@@ -238,4 +242,40 @@ object PayRepository {
}
/**
* 俩时间中的订单统计
*/
fun requestOrderQueryByTime(beginDate: Date, endDate: Date): QueryTradesByTimeResponse {
val shopInfo = AccountService.getAccountInfo()?.shopInfo
val baseUrl = shopInfo?.miyaPayPlatformUrl
val signKey = shopInfo?.miyaPayPlatformSignKey
val saasid = shopInfo?.saasid
val marketid = shopInfo?.storeId
val userId = shopInfo?.posId
val cashier = shopInfo?.operatorId
val beginDateStr = DateUtils.format14(beginDate)
val endDateStr = DateUtils.format14(endDate)
checkNotNull(baseUrl, { "PayRepository requestOrderQueryByTime baseUrl is null" })
checkNotNull(signKey, { "PayRepository requestOrderQueryByTime signKey is null" })
checkNotNull(saasid, { "PayRepository requestOrderQueryByTime saasid is null" })
checkNotNull(marketid, { "PayRepository requestOrderQueryByTime marketid is null" })
checkNotNull(userId, { "PayRepository requestOrderQueryByTime userId is null" })
checkNotNull(cashier, { "PayRepository requestOrderQueryByTime cashier is null" })
checkNotNull(beginDateStr, { "PayRepository requestOrderQueryByTime beginDate is null" })
checkNotNull(endDateStr, { "PayRepository requestOrderQueryByTime endDate is null" })
val paramsMap: MutableMap<String, Any> = HashMap()
paramsMap["baseUrl"] = baseUrl
paramsMap["key"] = signKey
paramsMap["version"] = "1"
paramsMap["saasid"] = saasid
paramsMap["marketid"] = marketid
paramsMap["userid"] = userId
paramsMap["cashier"] = cashier
paramsMap["begin_date"] = beginDateStr
paramsMap["end_date"] = endDateStr
return MiYaPlatformPayService.getService().syncQueryTrades(paramsMap)
}
}
\ No newline at end of file
......@@ -2,32 +2,40 @@ package com.miya.fastcashier.service
import android.text.TextUtils
import com.miya.fastcashier.beans.SelfCashierAccountInfo
import com.miya.fastcashier.beans.ViewOrderStatisticsInfo
import com.miya.fastcashier.utils.DateUtils
import com.miya.fastcashier.utils.MiYaPayPlantformPayWayEnum
import com.miya.fastcashier.utils.StringPriceFormat
import com.miya.fastcashier.utils.isEmpty
import com.miya.print.BuildConfig
import com.miya.print.IPrinter
import com.miya.print.PrinterManager
import com.miya.print.utils.Page58MmPrintUtils
import com.miya.print.utils.PrintLogger
import com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
import com.tencent.mmkv.MMKV
import java.lang.Exception
import java.util.*
object PrintService{
object PrintService {
private var payServiceResponse : PayServiceResponse? = null;
private var payServiceResponse: PayServiceResponse? = null;
/**
* 退款
*/
fun refundPrint(selfCashierAccountInfo: SelfCashierAccountInfo,payServiceResponse: PayServiceResponse){
fun refundPrint(
selfCashierAccountInfo: SelfCashierAccountInfo,
payServiceResponse: PayServiceResponse
) {
val printer = PrinterManager.getInstance().printer
printer.beginPrint()
//检查打印机状态
printer.printerStatus
printer.set58mm()
refundPrintCashier(printer,payServiceResponse,selfCashierAccountInfo)
refundPrintCustomer(printer,payServiceResponse,selfCashierAccountInfo)
refundPrintCashier(printer, payServiceResponse, selfCashierAccountInfo)
refundPrintCustomer(printer, payServiceResponse, selfCashierAccountInfo)
printer.feedPaper()
printer.endPrint()
}
......@@ -35,10 +43,10 @@ object PrintService{
/**
* 打印上一单
*/
fun printLastOrderInfo(){
if(payServiceResponse == null){
fun printLastOrderInfo() {
if (payServiceResponse == null) {
throw java.lang.RuntimeException("暂无上一单信息")
}else{
} else {
AccountService.getAccountInfo()?.let { payInfoPrint(payServiceResponse!!, it) }
}
}
......@@ -46,39 +54,156 @@ object PrintService{
/**
* 扣款信息打印
*/
fun payInfoPrint(payServiceResponse: PayServiceResponse,selfCashierAccountInfo: SelfCashierAccountInfo){
fun payInfoPrint(
payServiceResponse: PayServiceResponse,
selfCashierAccountInfo: SelfCashierAccountInfo
) {
//保存上一单信息
this.payServiceResponse = payServiceResponse
//记录流水号,退款要用
setSerialNoByOrderNo(payServiceResponse.shopTradeNo,getSerialNumber())
setSerialNoByOrderNo(payServiceResponse.shopTradeNo, getSerialNumber())
val printer = PrinterManager.getInstance().printer
printer.beginPrint()
//检查打印机状态
printer.printerStatus
printer.set58mm()
printCashier(printer,payServiceResponse,selfCashierAccountInfo)
printCustomer(printer,payServiceResponse,selfCashierAccountInfo)
if (BuildConfig.DEBUG) {
printCashier(printer, payServiceResponse, selfCashierAccountInfo)
} else {
printCashier(printer, payServiceResponse, selfCashierAccountInfo)
printCustomer(printer, payServiceResponse, selfCashierAccountInfo)
}
printer.feedPaper()
printer.endPrint()
}
/**
* 统计,给两个时间,
*/
fun printStatisticInfo(
viewOrderStatisticsInfo: ViewOrderStatisticsInfo,
selfCashierAccountInfo: SelfCashierAccountInfo,
) {
val printer = PrinterManager.getInstance().printer
printer.beginPrint()
//检查打印机状态
printer.printerStatus
printer.set58mm()
doPrintStatisticInfo(printer, viewOrderStatisticsInfo, selfCashierAccountInfo)
printer.feedPaper()
printer.endPrint()
}
private fun doPrintStatisticInfo(
printer: IPrinter,
orderStatisticsInfo: ViewOrderStatisticsInfo,
accountInfo: SelfCashierAccountInfo
) {
printer.beginPrint()
//[小票内容优化] 去除'欢迎光临'
printer.printText(accountInfo.shopInfo?.storeName ?: "")
//统计时间
printer.printText(0, 0, "开始时间:" + orderStatisticsInfo.beginDate, true)
printer.printText(0, 0, "结束时间:" + orderStatisticsInfo.endDate, true)
// //打印分割线-居左
printer.printText(0, 0, Page58MmPrintUtils.printDivideLineString(), true)
// //打印门店号、收银机号、收银员号在一行打印显示
if (!TextUtils.isEmpty(
accountInfo.shopInfo?.operatorId
)
) {
printer.printText(
Page58MmPrintUtils.printTwoData(
"门店号:" + accountInfo.shopInfo?.storeId
.toString() + " 收银机号:" + accountInfo.shopInfo?.posId,
"收银员号:" + accountInfo.shopInfo?.operatorId
)
)
} else {
printer.printText(
Page58MmPrintUtils.printTwoData(
"门店号:" + accountInfo.shopInfo?.storeId,
"收银机号:" + accountInfo.shopInfo?.posId
)
)
}
val totalStatistics: ViewOrderStatisticsInfo.StatisticBean? =
orderStatisticsInfo.totalStatistic
if (totalStatistics != null) {
printer.printText(0, 0, Page58MmPrintUtils.printDivideLineString(), true)
printer.printText(
Page58MmPrintUtils.printTwoData(
"总交易笔数",
"" + totalStatistics.tradeCount
)
)
printer.printText(
Page58MmPrintUtils.printTwoData(
"总交易金额",
"" + StringPriceFormat.transStringPriceToDecimalString(totalStatistics.tradeTotalAmount.toString())
)
)
}
val typedStatisticList: List<ViewOrderStatisticsInfo.StatisticBean> =
orderStatisticsInfo.typeStatistic
if (!isEmpty(typedStatisticList)) {
var statisticBean: ViewOrderStatisticsInfo.StatisticBean
for (i in typedStatisticList.indices) {
if (typedStatisticList[i] == null) {
continue
}
statisticBean = typedStatisticList[i]
printer.printText(0, 0, Page58MmPrintUtils.printDivideLineString(), true)
printer.printText(
Page58MmPrintUtils.printTwoData(
"支付方式",
statisticBean.payType
)
)
printer.printText(
Page58MmPrintUtils.printTwoData(
"交易笔数",
"" + statisticBean.tradeCount
)
)
printer.printText(
Page58MmPrintUtils.printTwoData(
"交易金额",
"" + StringPriceFormat.transStringPriceToDecimalString(statisticBean.tradeTotalAmount.toString())
)
)
}
}
}
/**
* 打印收银员联
*/
private fun printCashier(printer:IPrinter,payServiceResponse: PayServiceResponse,selfCashierAccountInfo: SelfCashierAccountInfo){
private fun printCashier(
printer: IPrinter,
payServiceResponse: PayServiceResponse,
selfCashierAccountInfo: SelfCashierAccountInfo
) {
val shopInfo = selfCashierAccountInfo.shopInfo
printer.printText(IPrinter.ALIGN_CENTER,3, shopInfo.storeName,true)
printer.printText(IPrinter.ALIGN_CENTER, 3, shopInfo.storeName, true)
printer.setAlign(IPrinter.ALIGN_LEFT)
printer.printText("商户编号:${shopInfo.saasid}")
printer.printText("终端编号:${shopInfo.posId}")
printer.printText("商户名称:converse")
printer.printText(Page58MmPrintUtils.printDivideLineString())
printer.printText("交易类型:")
printer.printText(IPrinter.ALIGN_LEFT,3, " ${ MiYaPayPlantformPayWayEnum.MiyaPayType.find(payServiceResponse.chanelTag).desc}",true)
printer.printText(
IPrinter.ALIGN_LEFT,
3,
" ${MiYaPayPlantformPayWayEnum.MiyaPayType.find(payServiceResponse.chanelTag).desc}",
true
)
printer.printText(Page58MmPrintUtils.printDivideLineString())
printer.printText("日期/时间:${DateUtils.format18(Date())}")
printer.printText("流水号:${getSerialNumber()}")
......@@ -87,7 +212,12 @@ object PrintService{
printer.printText("支付平台交易号:")
printer.printText(payServiceResponse.chanelSerialNumber)
printer.printText("金额:")
printer.printText(IPrinter.ALIGN_LEFT,3," RMB${StringPriceFormat.transStringPriceToDecimalString(payServiceResponse.tradPrice)}",true)
printer.printText(
IPrinter.ALIGN_LEFT,
3,
" RMB${StringPriceFormat.transStringPriceToDecimalString(payServiceResponse.tradPrice)}",
true
)
printer.printText(Page58MmPrintUtils.printDivideLineString())
printer.printText("备注:")
......@@ -100,8 +230,15 @@ object PrintService{
if (couponDetail.size >= 3 && !TextUtils.isEmpty(couponDetail[2]) && couponDetail[2] != "0" && couponDetail[2] != "0.00") {
//平台优惠
val platformCoupon = couponDetail[2]
val channel = MiYaPayPlantformPayWayEnum.MiyaPayType.find(payServiceResponse.chanelTag).desc
printer.printText("$channel 优惠:${StringPriceFormat.transStringPriceToDecimalString(platformCoupon)}元")
val channel =
MiYaPayPlantformPayWayEnum.MiyaPayType.find(payServiceResponse.chanelTag).desc
printer.printText(
"$channel 优惠:${
StringPriceFormat.transStringPriceToDecimalString(
platformCoupon
)
}"
)
}
if (couponDetail.isNotEmpty() && !TextUtils.isEmpty(couponDetail[0])) {
val payPrice = couponDetail[0]
......@@ -117,9 +254,13 @@ object PrintService{
/**
* 打印顾客联
*/
private fun printCustomer(printer:IPrinter,payServiceResponse: PayServiceResponse,selfCashierAccountInfo: SelfCashierAccountInfo){
private fun printCustomer(
printer: IPrinter,
payServiceResponse: PayServiceResponse,
selfCashierAccountInfo: SelfCashierAccountInfo
) {
val shopInfo = selfCashierAccountInfo.shopInfo
printer.printText(IPrinter.ALIGN_CENTER,3, shopInfo.storeName,true)
printer.printText(IPrinter.ALIGN_CENTER, 3, shopInfo.storeName, true)
printer.setAlign(IPrinter.ALIGN_LEFT)
printer.printText("持卡人存根")
printer.printText(Page58MmPrintUtils.printDivideLineString())
......@@ -128,7 +269,12 @@ object PrintService{
printer.printText("商户名称:converse")
printer.printText(Page58MmPrintUtils.printDivideLineString())
printer.printText("交易类型:")
printer.printText(IPrinter.ALIGN_LEFT,3, " ${ MiYaPayPlantformPayWayEnum.MiyaPayType.find(payServiceResponse.chanelTag).desc}",true)
printer.printText(
IPrinter.ALIGN_LEFT,
3,
" ${MiYaPayPlantformPayWayEnum.MiyaPayType.find(payServiceResponse.chanelTag).desc}",
true
)
printer.printText(Page58MmPrintUtils.printDivideLineString())
printer.printText("日期/时间:${DateUtils.format18(Date())}")
printer.printText("流水号:${getSerialNumber()}")
......@@ -137,7 +283,12 @@ object PrintService{
printer.printText("支付平台交易号:")
printer.printText(payServiceResponse.chanelSerialNumber)
printer.printText("金额:")
printer.printText(IPrinter.ALIGN_LEFT,3," RMB${StringPriceFormat.transStringPriceToDecimalString(payServiceResponse.tradPrice)}",true)
printer.printText(
IPrinter.ALIGN_LEFT,
3,
" RMB${StringPriceFormat.transStringPriceToDecimalString(payServiceResponse.tradPrice)}",
true
)
printer.printText(Page58MmPrintUtils.printDivideLineString())
printer.printText("备注:")
......@@ -150,8 +301,15 @@ object PrintService{
if (couponDetail.size >= 3 && !TextUtils.isEmpty(couponDetail[2]) && couponDetail[2] != "0" && couponDetail[2] != "0.00") {
//平台优惠
val platformCoupon = couponDetail[2]
val channel = MiYaPayPlantformPayWayEnum.MiyaPayType.find(payServiceResponse.chanelTag).desc
printer.printText("$channel 优惠:${StringPriceFormat.transStringPriceToDecimalString(platformCoupon)}元")
val channel =
MiYaPayPlantformPayWayEnum.MiyaPayType.find(payServiceResponse.chanelTag).desc
printer.printText(
"$channel 优惠:${
StringPriceFormat.transStringPriceToDecimalString(
platformCoupon
)
}"
)
}
if (couponDetail.isNotEmpty() && !TextUtils.isEmpty(couponDetail[0])) {
val payPrice = couponDetail[0]
......@@ -164,16 +322,25 @@ object PrintService{
/**
* 打印收银员联 - 退款
*/
private fun refundPrintCashier(printer:IPrinter,payServiceResponse: PayServiceResponse,selfCashierAccountInfo: SelfCashierAccountInfo){
private fun refundPrintCashier(
printer: IPrinter,
payServiceResponse: PayServiceResponse,
selfCashierAccountInfo: SelfCashierAccountInfo
) {
val shopInfo = selfCashierAccountInfo.shopInfo
printer.printText(IPrinter.ALIGN_CENTER,3, shopInfo.storeName,true)
printer.printText(IPrinter.ALIGN_CENTER, 3, shopInfo.storeName, true)
printer.setAlign(IPrinter.ALIGN_LEFT)
printer.printText("商户编号:${shopInfo.saasid}")
printer.printText("终端编号:${shopInfo.posId}")
printer.printText("商户名称:converse")
printer.printText(Page58MmPrintUtils.printDivideLineString())
printer.printText("交易类型:")
printer.printText(IPrinter.ALIGN_LEFT,3, " 退款(${ MiYaPayPlantformPayWayEnum.MiyaPayType.find(payServiceResponse.chanelTag).desc})",true)
printer.printText(
IPrinter.ALIGN_LEFT,
3,
" 退款(${MiYaPayPlantformPayWayEnum.MiyaPayType.find(payServiceResponse.chanelTag).desc})",
true
)
printer.printText(Page58MmPrintUtils.printDivideLineString())
printer.printText("日期/时间:${DateUtils.format18(Date())}")
printer.printText("流水号:${getSerialNoByOrderNo(payServiceResponse.shopTradeNo)}")
......@@ -182,7 +349,12 @@ object PrintService{
printer.printText("支付平台交易号:")
printer.printText(payServiceResponse.chanelSerialNumber)
printer.printText("金额:")
printer.printText(IPrinter.ALIGN_LEFT,3," RMB${StringPriceFormat.transStringPriceToDecimalString(payServiceResponse.refundPrice)}",true)
printer.printText(
IPrinter.ALIGN_LEFT,
3,
" RMB${StringPriceFormat.transStringPriceToDecimalString(payServiceResponse.refundPrice)}",
true
)
printer.printText("原订单号:")
printer.printText(payServiceResponse.shopTradeNo)
printer.printText(Page58MmPrintUtils.printDivideLineString())
......@@ -197,8 +369,15 @@ object PrintService{
if (couponDetail.size >= 3 && !TextUtils.isEmpty(couponDetail[2]) && couponDetail[2] != "0" && couponDetail[2] != "0.00") {
//平台优惠
val platformCoupon = couponDetail[2]
val channel = MiYaPayPlantformPayWayEnum.MiyaPayType.find(payServiceResponse.chanelTag).desc
printer.printText("$channel 优惠:${StringPriceFormat.transStringPriceToDecimalString(platformCoupon)}元")
val channel =
MiYaPayPlantformPayWayEnum.MiyaPayType.find(payServiceResponse.chanelTag).desc
printer.printText(
"$channel 优惠:${
StringPriceFormat.transStringPriceToDecimalString(
platformCoupon
)
}"
)
}
if (couponDetail.isNotEmpty() && !TextUtils.isEmpty(couponDetail[0])) {
val payPrice = couponDetail[0]
......@@ -214,9 +393,13 @@ object PrintService{
/**
* 打印顾客联-退款
*/
private fun refundPrintCustomer(printer:IPrinter,payServiceResponse: PayServiceResponse,selfCashierAccountInfo: SelfCashierAccountInfo){
private fun refundPrintCustomer(
printer: IPrinter,
payServiceResponse: PayServiceResponse,
selfCashierAccountInfo: SelfCashierAccountInfo
) {
val shopInfo = selfCashierAccountInfo.shopInfo
printer.printText(IPrinter.ALIGN_CENTER,3, shopInfo.storeName,true)
printer.printText(IPrinter.ALIGN_CENTER, 3, shopInfo.storeName, true)
printer.setAlign(IPrinter.ALIGN_LEFT)
printer.printText("持卡人存根")
printer.printText(Page58MmPrintUtils.printDivideLineString())
......@@ -225,7 +408,12 @@ object PrintService{
printer.printText("商户名称:converse")
printer.printText(Page58MmPrintUtils.printDivideLineString())
printer.printText("交易类型:")
printer.printText(IPrinter.ALIGN_LEFT,3, " 退款(${ MiYaPayPlantformPayWayEnum.MiyaPayType.find(payServiceResponse.chanelTag).desc})",true)
printer.printText(
IPrinter.ALIGN_LEFT,
3,
" 退款(${MiYaPayPlantformPayWayEnum.MiyaPayType.find(payServiceResponse.chanelTag).desc})",
true
)
printer.printText(Page58MmPrintUtils.printDivideLineString())
printer.printText("日期/时间:${DateUtils.format18(Date())}")
printer.printText("流水号:${getSerialNoByOrderNo(payServiceResponse.shopTradeNo)}")
......@@ -234,7 +422,12 @@ object PrintService{
printer.printText("支付平台交易号:")
printer.printText(payServiceResponse.chanelSerialNumber)
printer.printText("金额:")
printer.printText(IPrinter.ALIGN_LEFT,3," RMB${StringPriceFormat.transStringPriceToDecimalString(payServiceResponse.refundPrice)}",true)
printer.printText(
IPrinter.ALIGN_LEFT,
3,
" RMB${StringPriceFormat.transStringPriceToDecimalString(payServiceResponse.refundPrice)}",
true
)
printer.printText("原订单号:")
printer.printText(payServiceResponse.shopTradeNo)
printer.printText(Page58MmPrintUtils.printDivideLineString())
......@@ -249,8 +442,15 @@ object PrintService{
if (couponDetail.size >= 3 && !TextUtils.isEmpty(couponDetail[2]) && couponDetail[2] != "0" && couponDetail[2] != "0.00") {
//平台优惠
val platformCoupon = couponDetail[2]
val channel = MiYaPayPlantformPayWayEnum.MiyaPayType.find(payServiceResponse.chanelTag).desc
printer.printText("$channel 优惠:${StringPriceFormat.transStringPriceToDecimalString(platformCoupon)}元")
val channel =
MiYaPayPlantformPayWayEnum.MiyaPayType.find(payServiceResponse.chanelTag).desc
printer.printText(
"$channel 优惠:${
StringPriceFormat.transStringPriceToDecimalString(
platformCoupon
)
}"
)
}
if (couponDetail.isNotEmpty() && !TextUtils.isEmpty(couponDetail[0])) {
val payPrice = couponDetail[0]
......
......@@ -4,6 +4,7 @@ import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import com.miya.fastcashier.R
import com.miya.fastcashier.databinding.ActivityLoginBinding
......@@ -12,11 +13,13 @@ import com.miya.fastcashier.service.AccountService
import com.miya.fastcashier.service.PrintService
import com.miya.fastcashier.ui.dialog.MessageDialog
import com.miya.fastcashier.utils.CenterToasty
import com.miya.fastcashier.utils.DateSelectHelper
import com.miya.fastcashier.utils.clickWithTrigger
import com.miya.fastcashier.viewmodel.MainViewModel
import com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
import com.tencent.mmkv.MMKV
import java.lang.Exception
import java.util.*
class MainActivity : BaseActivity() {
......@@ -24,6 +27,7 @@ class MainActivity : BaseActivity() {
private var alertDialog: MessageDialog? = null
private lateinit var binding: ActivityMainBinding
private lateinit var viewModel: MainViewModel
private var dateSelectHelper: DateSelectHelper? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
......@@ -66,6 +70,29 @@ class MainActivity : BaseActivity() {
ivLoginOut.clickWithTrigger {
loginOut()
}
binding.llStatistic.clickWithTrigger {
if (dateSelectHelper == null) {
dateSelectHelper = DateSelectHelper(this@MainActivity) {
viewModel.orderStatistics(it,Date())
}
}
dateSelectHelper!!.showDatePicker()
}
initData()
}
private fun initData() {
viewModel.statisticsLiveData.observe(this, { result ->
result.onSuccess {
}
result.onFailure { e ->
CenterToasty.error(this@MainActivity, e.message ?: "").show()
}
})
}
......@@ -88,4 +115,9 @@ class MainActivity : BaseActivity() {
}
alertDialog?.show()
}
override fun onDestroy() {
dateSelectHelper?.dismiss()
super.onDestroy()
}
}
\ No newline at end of file
......@@ -5,18 +5,27 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import com.miya.fastcashier.R
import com.miya.fastcashier.beans.ViewPayOrderData
import com.miya.fastcashier.dao.PayDataDao
import com.miya.fastcashier.databinding.ActivitySearchOrderBinding
import com.miya.fastcashier.databinding.FragmentSearchOrderBinding
import com.miya.fastcashier.databinding.ItemSearchOrderListBinding
import com.miya.fastcashier.utils.CenterToasty
import com.miya.fastcashier.utils.MiYaPayPlantformPayWayEnum
import com.miya.fastcashier.utils.StringPriceFormat
import com.miya.fastcashier.utils.clickWithTrigger
import com.miya.fastcashier.viewmodel.SearchOrderViewModel
import com.miya.fastcashier.widget.Divider
/**
* 查单列表
......@@ -56,16 +65,18 @@ class SearchOrderActivity : BaseActivity() {
}
}.attach()
}
}
class SearchOrderFragment(payType: MiYaPayPlantformPayWayEnum.MiyaPayType) : Fragment() {
class SearchOrderFragment(val payType: MiYaPayPlantformPayWayEnum.MiyaPayType) : Fragment() {
private var binding: FragmentSearchOrderBinding? = null
private lateinit var adapter: SearchOrderListAdapter
private lateinit var vm: SearchOrderViewModel
private var onLoading = false
private var isEnd = false
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
......@@ -80,21 +91,74 @@ class SearchOrderFragment(payType: MiYaPayPlantformPayWayEnum.MiyaPayType) : Fra
if (activity == null) {
return
}
isEnd = false
onLoading = false
val act = requireActivity()
binding?.run {
adapter = SearchOrderListAdapter(act, arrayListOf())
rvContent.layoutManager = LinearLayoutManager(act, LinearLayoutManager.VERTICAL, false)
rvContent.adapter = adapter
rvContent.addItemDecoration(Divider(act))
rvContent.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
//用来标记是否正在向最后一个滑动
var isSlidingToLast = false
override fun onScrollStateChanged(
recyclerView: RecyclerView,
newState: Int
) {
if (isEnd) { //如果已经加载完成,就不处理
return
}
val manager = recyclerView.layoutManager as LinearLayoutManager?
// 当不滚动时
if (manager != null && newState == RecyclerView.SCROLL_STATE_IDLE) {
//获取最后一个完全显示的ItemPosition
val lastVisibleItem = manager.findLastCompletelyVisibleItemPosition()
val totalItemCount = manager.itemCount
// 判断是否滚动到底部,并且是向右滚动
if (!onLoading && totalItemCount > 5 && lastVisibleItem > totalItemCount - 5 && isSlidingToLast) { //滑到最后5条的时候,如果不是列表已经结束,那么就
//加载更多功能的代码
onLoading = true
loadMore(adapter.itemCount)
}
}
}
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
//dx用来判断横向滑动方向,dy用来判断纵向滑动方向
isSlidingToLast = dy > 0
}
})
}
vm = ViewModelProvider(this).get(SearchOrderViewModel::class.java)
vm.payDataLiveData.observe(act) {
onLoading = false
it.onFailure { e ->
CenterToasty.error(act, e.message ?: "", Toast.LENGTH_LONG).show()
}
it.onSuccess { list ->
val oldSize = adapter.getDataSource().size
adapter.getDataSource().addAll(list)
if (oldSize == 0) {
adapter.notifyDataSetChanged()
} else {
adapter.notifyItemInserted(oldSize)
}
if (list.size < PayDataDao.NUM_OF_SINGLE_PAGE) {//如果不足20条,表示已经到底,不用查了
isEnd = true
}
}
}
loadMore(0)
}
private fun loadMore(loadIndex: Int) {
//加载更多
vm.getPayData(payType, loadIndex)
onLoading = true
}
override fun onDestroyView() {
......@@ -123,13 +187,28 @@ class SearchOrderListAdapter(
return list.size
}
fun getDataSource(): MutableList<ViewPayOrderData> {
return list
}
}
class SearchOrderViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
private val binding: ItemSearchOrderListBinding = ItemSearchOrderListBinding.bind(itemView)
fun setData(data: ViewPayOrderData) {
binding.tvDate.text = data.chanelOrderTradeTime
if (data.refundOrderNo != null && data.refundPrice != null) {
binding.tvRefundTag.visibility = View.VISIBLE
binding.tvPrice.text =
"¥" + StringPriceFormat.transStringPriceToDecimalString(data.refundPrice)
binding.tvOrderNo.text = data.refundOrderNo
} else {
binding.tvRefundTag.visibility = View.GONE
binding.tvPrice.text =
"¥" + StringPriceFormat.transStringPriceToDecimalString(data.tradPrice)
}
}
}
\ No newline at end of file
package com.miya.fastcashier.utils
import android.text.TextUtils
fun isEmpty(s: String?): Boolean {
return TextUtils.isEmpty(s)
}
fun isEmpty(list: List<Any>?): Boolean {
return list != null && list.isNotEmpty()
}
\ No newline at end of file
package com.miya.fastcashier.utils
import android.content.Context
import android.graphics.Color
import android.view.View
import android.view.ViewGroup
import androidx.core.content.res.ResourcesCompat
import com.bigkoo.pickerview.builder.TimePickerBuilder
import com.bigkoo.pickerview.listener.OnTimeSelectListener
import com.bigkoo.pickerview.view.TimePickerView
import com.miya.fastcashier.R
import java.util.*
class DateSelectHelper(val context: Context, val callback: (Date) -> Unit) {
var timePickerView: TimePickerView? = null
fun showDatePicker() {
if (timePickerView == null) {
initTimePicker()
}
val date = Calendar.getInstance()
date.set(
date.get(Calendar.YEAR),
date.get(Calendar.MONTH),
date.get(Calendar.DAY_OF_MONTH),
0,
0
)
timePickerView!!.setDate(date)
timePickerView!!.show()
}
private fun initTimePicker() {
val calendar = Calendar.getInstance()
val startDate = Calendar.getInstance()
val endDate = Calendar.getInstance()
startDate.set(
calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH),
0,
0
)
endDate.set(
calendar.get(Calendar.YEAR),
calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH),
calendar.get(Calendar.HOUR_OF_DAY),
calendar.get(Calendar.MINUTE)
)
timePickerView = TimePickerBuilder(context, OnTimeSelectListener { date, v ->
callback(date)
})
.setTitleText("请选择开始时间")
.setType(booleanArrayOf(false, false, false, true, true, false))
.setDate(startDate)
.setRangDate(startDate, endDate)
.build()
}
fun dismiss() {
timePickerView?.dismiss()
}
}
\ No newline at end of file
......@@ -5,18 +5,26 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.miya.fastcashier.beans.LoginRequest
import com.miya.fastcashier.beans.SelfCashierAccountInfo
import com.miya.fastcashier.beans.ViewOrderStatisticsInfo
import com.miya.fastcashier.repository.PayRepository
import com.miya.fastcashier.service.AccountService
import com.miya.fastcashier.service.LoginService
import com.miya.fastcashier.service.PrintService
import com.miya.fastcashier.utils.DateUtils
import com.sdy.miya.moblie.component.pay.platform.bean.MiyaOrderRefundResponse
import kotlinx.coroutines.*
import java.lang.Exception
import java.lang.RuntimeException
import java.util.*
import kotlin.collections.HashMap
class MainViewModel : ViewModel() {
val refundLiveData: MutableLiveData<Result<PayRepository>> = MutableLiveData()
val statisticsLiveData: MutableLiveData<Result<Boolean>> = MutableLiveData()
/**
* oriOrderNo 原订单号
* refundOrderNo 退款订单号
......@@ -25,9 +33,9 @@ class MainViewModel : ViewModel() {
fun refund(oriOrderNo: String, refundOrderNo: String, refundPrice: String) = runBlocking {
val refundParams = HashMap<String, String>()
refundParams["oriOrderNo"] = oriOrderNo;
refundParams["refundOrderNo"] = refundOrderNo;
refundParams["refundPrice"] = refundPrice;
refundParams["oriOrderNo"] = oriOrderNo
refundParams["refundOrderNo"] = refundOrderNo
refundParams["refundPrice"] = refundPrice
val refundResult = async(Dispatchers.IO) {
PayRepository.refundByOrderNo(refundParams)
......@@ -44,4 +52,32 @@ class MainViewModel : ViewModel() {
}
/**
* 订单统计
*/
fun orderStatistics(beginDate: Date, endDate: Date) {
val accountInfo = AccountService.getAccountInfo()
if (accountInfo == null) {
statisticsLiveData.value = Result.failure(RuntimeException("账户数据为空"))
return
}
val accountInfoFinal = accountInfo!!
viewModelScope.launch(Dispatchers.IO) {
try {
val response = PayRepository.requestOrderQueryByTime(beginDate, endDate)
val info = ViewOrderStatisticsInfo.transfer(
response,
DateUtils.format18(beginDate),
DateUtils.format18(endDate)
)
PrintService.printStatisticInfo(info, accountInfoFinal)
statisticsLiveData.postValue(Result.success(true))
} catch (e: Exception) {
e.printStackTrace()
statisticsLiveData.postValue(Result.failure(e))
}
}
}
}
\ No newline at end of file
......@@ -36,8 +36,6 @@ class PayViewModel : ViewModel() {
fun refund(payServiceResponse: PayServiceResponse) {
XLog.d("开始退款:${JSON.toJSONString(payServiceResponse)}")
viewModelScope.launch(Dispatchers.IO) {
//保存到数据库
ViewPayOrderData.insert(payServiceResponse)
//退款
var refundPayServiceResponse: PayServiceResponse? = null
try {
......@@ -48,8 +46,11 @@ class PayViewModel : ViewModel() {
refundParams["refundOrderNo"] = refundOrderNo
refundParams["refundPrice"] = payServiceResponse.tradPrice
refundPayServiceResponse = PayRepository.refundByOrderNo(refundParams)
refundLiveData.postValue(Result.success(refundPayServiceResponse))
XLog.d("退款成功:${JSON.toJSONString(refundPayServiceResponse)}")
//保存到数据库
ViewPayOrderData.insert(payServiceResponse)
refundLiveData.postValue(Result.success(refundPayServiceResponse))
} catch (e: Exception) {
e.printStackTrace()
XLog.d("退款异常:${e.message}")
......
package com.miya.fastcashier.viewmodel
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.miya.fastcashier.beans.ViewPayOrderData
import com.miya.fastcashier.dao.DatabaseKeeper
import com.miya.fastcashier.utils.MiYaPayPlantformPayWayEnum
import com.sdy.miya.moblie.component.pay.platform.bean.PayServiceResponse
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import java.lang.Exception
class SearchOrderViewModel {
class SearchOrderViewModel : ViewModel() {
val payDataLiveData: MutableLiveData<Result<List<ViewPayOrderData>>> = MutableLiveData()
fun getPayData() {
/**
* 获取
*/
fun getPayData(payType: MiYaPayPlantformPayWayEnum.MiyaPayType, currentSize: Int) {
viewModelScope.launch(Dispatchers.IO) {
try {
val list =
DatabaseKeeper.payDatabase.payDataDao()
.queryWithType(payType = payType.code, currentSize)
payDataLiveData.postValue(Result.success(list))
} catch (e: Exception) {
e.printStackTrace()
payDataLiveData.postValue(Result.failure(e))
}
}
}
}
\ No newline at end of file
package com.miya.fastcashier.widget;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.view.View;
import androidx.recyclerview.widget.RecyclerView;
import com.miya.fastcashier.R;
/**
* 通用的RecyclerDivider
*/
public class Divider extends RecyclerView.ItemDecoration {
private Paint paint;
private int divideWidth;
public Divider(Context context) {
this.paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(context.getResources().getColor(R.color.color_ECECEC));
divideWidth = 1;
}
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
int left = parent.getPaddingStart();
int right = parent.getMeasuredWidth() - parent.getPaddingEnd();
View child;
int childPosition;
int validChildCount = parent.getChildCount();
for (int i = 0; i < validChildCount; i++) {
child = parent.getChildAt(i);
childPosition = parent.getChildAdapterPosition(child);
if (childPosition == validChildCount - 1) {
break;
}
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) child.getLayoutParams();
int top = child.getBottom() + layoutParams.bottomMargin;
int bottom = top + divideWidth;
c.drawRect(left, top, right, bottom, paint);
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="15dp"
android:right="15dp">
<shape>
<gradient
android:endColor="#D73672"
android:startColor="#FF4B8A" />
<corners android:radius="40px" />
</shape>
\ No newline at end of file
<corners android:radius="40dp" />
</shape>
</item>
</layer-list>
\ No newline at end of file
......@@ -15,9 +15,13 @@
android:layout_marginTop="87dp"
android:background="@color/white"
app:layout_constraintTop_toTopOf="parent"
app:tabIndicator="@drawable/app_search_indicator"
app:tabGravity="fill"
app:tabIndicatorColor="#FF4B8A"
app:tabIndicatorFullWidth="false"
app:tabIndicatorHeight="5dp"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/color_333333"
app:tabMaxWidth="0dp"
app:tabTextAppearance="@style/tabText" />
<androidx.viewpager2.widget.ViewPager2
......
......@@ -6,5 +6,6 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvContent"
android:layout_width="match_parent"
android:paddingStart="40dp"
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -3,13 +3,12 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content">
<TextView
android:id="@+id/tvOrderNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:layout_marginTop="24dp"
android:textColor="@color/color_333333"
android:textSize="28sp"
......@@ -21,7 +20,36 @@
android:id="@+id/tvDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="26dp"
android:textColor="@color/color_666666"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="@id/tvOrderNo"
app:layout_constraintTop_toBottomOf="@id/tvOrderNo"
tools:text="2022-02-28 13:51:00" />
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/tvPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="40dp"
android:textColor="@color/color_333333"
android:textSize="32sp"
app:layout_constraintBaseline_toBaselineOf="@id/tvOrderNo"
app:layout_constraintEnd_toEndOf="parent"
tools:text="¥200.99" />
<TextView
android:id="@+id/tvRefundTag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:textColor="@color/color_FF4E33"
android:textSize="20sp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="@id/tvPrice"
app:layout_constraintTop_toBottomOf="@id/tvPrice"
tools:text="退款金额" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -10,4 +10,7 @@
<color name="green">#06C261</color>
<color name="blue">#2E6CFB</color>
<color name="color_333333">#333333</color>
<color name="color_666666">#666666</color>
<color name="color_FF4E33">#FF4E33</color>
<color name="color_ECECEC">#ECECEC</color>
</resources>
\ No newline at end of file
......@@ -18,5 +18,7 @@
<string name="search">查询</string>
<string name="statistic">统计</string>
<string name="balance">结算</string>
<string name="cancel">取消</string>
<string name="sure">确定</string>
</resources>
\ No newline at end of file
......@@ -17,9 +17,9 @@
<item name="DialogSpotCount">4</item>
</style>
<style name="tabText">
<style name="tabText" parent="TextAppearance.Design.Tab">
<item name="android:textSize">32sp</item>
<item name="android:textColor">@color/color_333333</item>
<item name="android:textColor">@color/color_666666</item>
<item name="android:lines">1</item>
<item name="android:maxLines">1</item>
</style>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment